Regex help: Scanner delimiter that splits on commas if not in form (1,1)

I have a scanner that reads in a LIST of commands:
4=ATEXTSTRING(499,329)$3,5=ATEXTSTRING(342,3),8=SFDS(1,1)
I want to have the scanner use the comma delimiter to get each of those three commands individually, but I dont want it to split on that comma in the coordinate.
I've tried this:
Scanner.useDelimiter("(?=,)((?!\\(\\d*,\\d*\\)).)*$");
but that's just not working.
It splits into:
Starburst(200,200)$0,4
Pentagon_Flight_Part1(200

@OP: You could try something like this:
String text = "4=ATEXTSTRING(499,329)$3,5=ATEXTSTRING(342,3),8=SFDS(1,1)";
//coordinates can have a maximum of 5 digits:
Scanner scan = new Scanner(text).useDelimiter("(?<!\\(\\d{1,5}),");
while(scan.hasNext()) {
  System.out.println(scan.next());
}

Similar Messages

  • Help! Flash error: 1088 (Markup in doucment not well-formed)

    I'm trying to use ASP.NET to retrieve data from the sql server, place in inside an xml and sends the xml to flash to display the data.
    However, I'm getting
    TypeError: Error #1088: The markup in the document following the root element must be well-formed.
    at news_fla::mainTimeline/loaded()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()
    This is my code:
    ASP.NET
    =======
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim adapter As SqlDataAdapter
            Dim ds As New DataSet
            Dim sql As String
            Dim con As New SqlConnection("data source = GN80000798-0\SQLEXPRESS2008; initial catalog = EL; integrated security = true")
            sql = "select * from news"
            Try
                con.Open()
                adapter = New SqlDataAdapter(sql, con)
                adapter.Fill(ds, "data")
                con.Close()
                Response.ContentType = "text/XML"
                Response.HeaderEncoding = Encoding.UTF8
                ds.WriteXml(Response.OutputStream, XmlWriteMode.WriteSchema)
                MsgBox("Done")
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
        End Sub
    Flash
    ====
    import flash.xml.*;
    var newsrequest:URLRequest = new URLRequest("http://localhost:1179/DB/DB.aspx"); //ASP.NET development server
    var newsloader:URLLoader = new URLLoader();
    var newsxml:XML;
    var dvar:URLVariables = new URLVariables();
    dvar.dummy = "dummy";
    newsrequest.data = dvar;
    newsrequest.method = URLRequestMethod.POST;
    newsloader.load(newsrequest);
    newsloader.addEventListener(Event.COMPLETE, loaded);
    titlenews.autoSize = TextFieldAutoSize.LEFT;
    bodynews.autoSize = TextFieldAutoSize.LEFT;
    function loaded(event:Event){
    newsxml = new XML(event.target.data);
    newsxml.ignoreWhitespace = true;
    trace(newsxml);
    HOWEVER, if i replace the
    "ds.WriteXml(Response.OutputStream, XmlWriteMode.WriteSchema)"
    with
    "ds.WriteXml("C:\new.xml")
    it works. But i dont wan a .xml file residing in the server. so i hope that the .xml file would be cleared off as soon as the request is done.
    Did i do something wrong?
    PS: I don't know if i post this in the correct section but since it's related to AS3, thats why i post it here. sorry if i made a mistake.

    Please paste the following line as first statement in loaded function, also compare the output of the following line with expected output from ASP page.
    trace(event.target.data);
    The error is causing due to the fact that XML received is not well formed.
    I guess the problem is with write XML you are getting some additional tag elements and these are not wellformed. so flash is giving error.

  • I have just installed os x mavericks. Before that, I usually writes gmail notes using the App Mail since they're always shown from the column under "Gmail". However, I couldn't find it now. Anyone knows how to do with it, please?

    Thanks a lot.

    Howdy BubbleRabbit,
    It sounds like you want to continue using the Notes function of your Gmail account but cannot find the option in the Mail application. In Mac OS X 10.9 there is a separate app called Notes that you can add your Gmail account to. This article will help you get that account setup:
    iOS: Syncing Notes
    http://support.apple.com/kb/HT4191?viewlocale=en_US
    Notes are associated with an IMAP email account or iCloud account. To sync Notes, enable Notes for each account in Settings > Mail, Contacts, Calendars or Settings > iCloud.
    Thank you for using Apple Support Communities!
    Regards,
    Sterling

  • Splitting of comma delimited string CONNECT BY Clause

    Hi ,
    I have got a problem in splitting a comma separated strings into rows .
    I am explaining the use case below :
    i have a table x_imp
    --> create table x_imp (id number, int_status varchar2(100),c_ref varchar2(30), s_ref varchar2(30));
    I inserted values into the table :
    insert into x_imp (id, int_status,c_ref,s_ref) values (1,'a1,a2,a3,a4','A','AS');
    insert into x_imp (id, int_status,c_ref,s_ref) values (1,'b1,b2,b3,b4','B', 'BS');
    insert into x_imp (id, int_status,c_ref,s_ref) values (1,'c1,c2,c3,c4', 'C', null);
    insert into x_imp (id, int_status, cust_ref, site_ref) values (1,NULL, 'D', NULL);
    I need to split the comma separated int_status into individual rows . That means my expected result is :
    . What I need or looking for as expected result:
    1, A, AS, a1
    1, A, AS, a2
    1, A, AS, a3
    1, A, AS, a4
    1, B, BS, b1
    1, B, BS, b2
    1, B, BS, b3
    1, B, BS, b4
    1, C, null, c1
    1, C, null, c2
    1, C, null, c3
    1, C, null, c4
    I currently have a solution using Regex . But this solution uses UNIQUE keyword .
    The solution i have currently :
    select UNIQUE c_ref,s_ref, regexp_substr(int_status,'[^,]+', 1, level) error_code
    from x_imp
    connect by regexp_substr(int_status, '[^,]+', 1, level) is not null;
    I need a better solution . Any pointers ?
    Thanks,
    Bibin

    One way of doing using MODEL clause:
    select c_ref, s_ref, res err_code
      FROM x_imp
    model
    partition by ( id, c_ref, s_ref)
    dimension by ( 1 rn)
    measures( int_status, cast(null as varchar2(100)) res,
              nvl(length(regexp_replace(int_status, '[^,]')),0)+1 nb )
    (res[for rn from 1 to nb[1] increment 1]=regexp_substr(int_status[1], '[^,]+', 1, cv(rn)))
    order by c_ref, s_ref;
    C_REF                          S_REF                          ERR_CODE                                                                                            
    A                              AS                             a3                                                                                                  
    A                              AS                             a4                                                                                                  
    A                              AS                             a1                                                                                                  
    A                              AS                             a2                                                                                                  
    B                              BS                             b2                                                                                                  
    B                              BS                             b1                                                                                                  
    B                              BS                             b3                                                                                                  
    B                              BS                             b4                                                                                                  
    C                                                             c4                                                                                                  
    C                                                             c3                                                                                                  
    C                                                             c1                                                                                                  
    C                                                             c2                                                                                                  
    D                                                                                                                                                                 
    13 rows selected

  • Possible to capture the delimiter with split(String, regex)?

    If StringTokenizer is frowned on, is it possilble to capture the delimiter in the string array when using split()?

    In Perl, all you have to do is put parentheses around the regex to have the delimiters returned as tokens. I can understand why the Sun devs left that feature out, though: it would make split's behavior twice as confusing as it already is. Anyway, I can't think of a better way to do it than your lookaround method, Sabre.
    If StringTokenizer is frowned on,
    Says who?Says the docs, actually. They say to use split() instead, as if it were a drop-in replacement for StringTokenizer. Then they confuse people even more by implying that split("\\s") is equivalent to the default behavior of StringTokenizer (it should be split("\\s+")). I submitted a bug report about that, but they didn't want to hear it.

  • Scanner delimiter problems...

    hey everyone,
    I am attempting to read from a file using Scanner and wanted to change the delimiter so that it would read through the file and pick out the info I need.
    However when i try
    Scanner inputStream = new Scanner(new FileReader(file));
                    inputStream.useDelimiter("\\n(), *[]");I get the following error after my program runs.
    java.util.regex.PatternSyntaxException: Unclosed character class near index 8
    \n(), *[]
    ^
    (the carrot should be under the last bracket)
    I think its because the parenthesis and brackets need to be expressed in a different way? I checked out the Pattern class but couldn't find anything with parenthesis. hoping you guys could help
    Thanks in advance,
    Tomek
    Edited by: sstomek on May 4, 2008 3:55 PM

    how can I escape those characters? Well even if i do not use the square brackets or parenthesis or asterisks, true the error does go away but my output is still not correct. Let me elaborate a bit. Here is an extended bit of my code...
    Scanner inputStream = new Scanner(new FileReader(file));
                    inputStream.useDelimiter("\\n\\s");
                    if (inputStream.hasNextInt())
                        numVertices = inputStream.nextInt();
                    System.out.println(numVertices);the beginning of the file I am reading from looks like this:
    25
    (934.39, 893.10)
    (336.22, 622.56)
    (205.64, 835.67)
    (527.40, 188.27)
    ........and so on for 21 more lines
    So the only information that is important to me is that first integer and then those double pairs. So I want the scanner to omit any spaces, commas, parenthesis, and brackets.
    However my output is 0 instead of 25
    -Tomek
    Edited by: sstomek on May 4, 2008 4:32 PM
    Edited by: sstomek on May 4, 2008 4:36 PM

  • Regex pattern, filter delimiter in sql code

    Hi,
    The problem I'm having is that the regex pattern below is not catching the beginning "go" and ending "go" of a string.
    "(?iu)[(?<=\\s)]\\bgo\\b(?=\\s)"
    The idea is catching the "whole word", in this case the word is "go" so if the word is at the beginning of the string or at the end, i still want to include it.
    So, for example:
    "go select * from table1 go" -> should catch 2 "go"s but catches 0
    "go go# select * from table1 --go go" -> should also catch 2 "go"s but catches 0
    "go go select * from table1 go go" -> should catch 4 "go"s but catches 2
    I have the "[(?<=\\s)]" and the "(?=\\s)" so that the word "go" when next to a special character is not included, for example "--go".
    The problem is that this also negates the beginning and ending of the string.
    Code to test example: It should split at 1st, 2nd and last "go", but only splits at the 2nd "go".
    String s = "go go select * from table1 --go go";
    String delimiter = "go";
    String[] queries = s.split("(?iu)[(?<=\\s)]\\b" + delimiter + "\\b(?=\\s)");
    for (int i = 0; i < queries.length; i++) {
         System.out.println(queries[i]);
    I really need to fix this but I'm not having much success.
    Any help will be appreciated, thanks in advance.

    Yes,
    I prefer this one: Regex Powertoy (interactive regular expressions)
    It's not 100% perfect, but you can see with my example and this online tester that the 1st "go" is not matched. And this is a problem for me.
    I want to eliminate the special characters like "#go" or "-go" but i don't want to eliminate the end and start of string.

  • I have a huge file which is in GB and I want to split the video into clip and export each clip individually. Can you please help me how to split and export the videos to computer? It will be of great help!!

    I have a huge file which is in GB and I want to split the video into clip and export each clip individually. Can you please help me how to split and export the videos to computer? It will be of great help!!

    video
    What version of Premiere Elements do you have and on what computer operating system is it running?
    Please review the following workflow.
    ATR Premiere Elements Troubleshooting: PE11: Project Assets Organization for Scene and Highlight Grabs from Collection o…
    But please also determine if your project goal is supported by
    a. format of your source
    and
    b. computer resources
    More later based on details that you will post.
    ATR

  • Xml regex help - can't use xml parser

    Hi,
    I receive xmls from a legacy system and use JAXB to parse these xml's into java objects.
    The xml looks roughly like this:
    <root-Tag>
       <general-Info-Tag-1>blah</<general-Info-Tag-1>
       <general-Info-Tag-2>blah</<general-Info-Tag-2>
       <general-Info-Tag-3>blah</<general-Info-Tag-3>
       <entry-Tag>
          <entry-info-Tag-1>info</entry-info-Tag-1>
          <entry-info-Tag-2>info</entry-info-Tag-2>
           etc...
       </entry-Tag>
       <entry-Tag>
          <entry-info-Tag-1>info</entry-info-Tag-1>
          <entry-info-Tag-2>info</entry-info-Tag-2>
           etc...
       </entry-Tag>
    </root-Tag>The xml contains a root tag.
    The root element contains some general info tags and entry tags.
    The entry elements contain some entry relevant info inside nested tags.
    It's important to note that this the xml is not nested anymore than the entry-info tags.
    My Problem:
    The info in the entry-info-tags sometimes contains illegal chars like <,>,& and is not wrapped
    properly by a CDATA section.
    So I need to find these elements and wrap them with <![CDATA[info]]> before using JAXB.
    How can I achieve this using Pattern/Matcher? I've been unsuccessful so far...
    Edited by: Samuelz on Jul 1, 2010 1:58 AM

    Heres what i've got so far:
    A helpful function to print out matches for regex on an input string:
    private static void printMathces(final String regex, final String input) {
         Pattern p = Pattern.compile(regex, Pattern.DOTALL);
         Matcher m = p.matcher(input);
         while (m.find()){
              System.out.println("found:");
              for (int i = 0; i < m.groupCount(); i++)
                   System.out.println(i + ":" + m.group(i));
    }My input string for testing:
    String s =
    "<entries>\n"+
         "<entry>\n" +
              "<TagName>sam&max</TagName>\n" +
         "</entry>\n" +
         "<entry>\n" +
              "<TagName><![CDATA[sam&max]]></TagName>\n" +
         "</entry>\n" +
    "</entries>\n";regex to get contents of TagName:
    printMatches("<(TagName)>((.*?))</\\1>+", s);
    found:
    0:<TagName>sam&max</TagName>
    1:TagName
    2:sam&max
    found:
    0:<TagName><![CDATA[sam&max]]></TagName>
    1:TagName
    2:<![CDATA[sam&max]]>regex to get content of TagName when its wrapped by CDATA
    printMathces("<(TagName)><!\\[CDATA\\[((.*?))\\]\\]></\\1>", s);
    found:
    0:<TagName><![CDATA[sam&max]]></TagName>
    1:TagName
    2:sam&maxI'm trying to build a regex that will find the contents of TagName without knowing if its already wrapped by CDATA and then replace these matches by something like <$1><![CDATA[$2]]</$1>
    How do I "combine" these 2 regular expressions?

  • Attachments dont download from Gmail in Safari, They disappear,I even tried re-downloading Safari and that download disappeared, it is not in my downloads folder, I actually searched in finder for the file and it is nowhere on my computer.  Please help!

    Attachments dont download from Gmail in Safari, They disappear,I even tried re-downloading Safari and that download disappeared, it is not in my downloads folder, I actually searched in finder for the file and it is nowhere on my computer.  Please help!

    Oh my gosh I had the EXACT same problem, and for ages I couldn't figure out how to fix it until today. Here's what I did:
    First I went onto my computer, opened itunes, and un-installed tumblr, vine and kik. These were the apps I was having problems with (it said I had them on my phone but, like you, they didn't show).
    Then I went to the itunes store, searched for each one, and it said I could update them so I did (just FYI: for tumblr a window popped up saying "please click ok to confirm you are 17 years or older", so I did that also)
    When I went back to my phone and tried installing them again (still on my computer), it worked!
    I hope this helps, because it was incredibly frustrating. Good luck!

  • The App store stopped accepting my credit card all of a sudden. It says that my credit card is "not supported by the Chilean app store"... The credit card is Chilean and was working just fine. Help!

    This is the second time this happens. I was living in the US until April 2011. I moved to Chile and kept using the App Store and the iTunes Store just fine with my US-issued credit card. However, when I accessed my Apple ID from a different device, the store stopped recognizing my credit card information and migrated my ID to the "Chilean" App & Itunes Store (significantly less apps & music... but anyway). I started using my Chilean credit card on the App and iTunes store with no issues. I supposed that the devices catched that I was no longer in the US and that I had to be transferred to the related store (which I think is fine), and that because I was now in the Chilean store I needed to use a Chilean-issued credit card (which doesn't make sense to me, I still don't understand why Apple stopped accepting my US credit card if it is accepted everywhere else in the world online and offline!).
    However, yesterday I bought something from my iPad and when today I went to use the app store from my iPhone the SAME THING happened. I got the same request to "update my billing information", I confirmed my Chilean credit card info and, surprise! "Your credit card is not supported by the Chilean app store"...
    I don't get it. If I didn't get it the first time, I ended up accepting it an getting over it because ok, I moved to another country and my account was migrated, etc. But now, it doesn't recognize my local credit card in my local store! I tried both my local Visa and my local MasterCard, and none of them worked. It looks like my account will not accept ANY credit card, no matter wheter I try to update the info from my mobile devices, on iTunes, on the Mac App Store, etc.
    It has been impossible for me to find any information on what causes this and on how to solve it, and so far I hadn't had any trouble with Apple and hadn't need any support before, but now that I need URGENT SUPPORT, I've come to realize that THEY SUCK at being accessible! There's no way I can contact them! So, please help me!!!!! I need urgent help!!!!
    Thanks and sorry for the very long post.

    Same thing happened to me with my peruvian credit card in the peruvian app store, I want to buy an app, but it says that my credit card is "not supported in the Peruvian app store"

  • I recently reset my computer and copy my music from an external hard drive to my itunes library.  When I click on a song to play i get an error message that says " the song could not be used because the original file could not be found".  need help

    I recently reset my computer and copy my music from an external hard drive to my itunes library.  When I click on a song to play i get an error message that says " the song could not be used because the original file could not be found".  But when I have my external hard drive plug in the song will play with no problem.  What do I need to do to play my music without having the external harddrive plug in ????????  Please help

    Because the location for each song in your library is on your hard drive.  If the hard drive isn't there, how can iTunes play it?
    You'll have to move/copy the music from your hard drive to your computer's hard drive.
    Basically, EASIEST way to do all this, if you don't care about your play counts, etc...
    -Delete EVERYTHING from iTunes, so that your library is now empty.
    -Go to "Advanced" inside of the "Preferences" window, found in the "Edit" drop-down.  You can also access Preferences by pressing Ctrl+, (Press Ctrl and the comma key)
    -Change your iTunes Media Folder Location to something simple, but on your computer. I use C:/iTunes.  Make sure "Keep iTunes Media Folder Organized" and "Copy files to...." are both checked.  You can close Preferences now.
    -Now, drag and drop your music from your hard drive into your iTunes library.  iTunes will automatically add the music to your library, as you would expect, and also creates a copy of each file to place into that iTunes Media Folder you just created.
    Shouldn't have any more problems...

  • How can I relocate songs from my Itunes? Itunes tells me that the original files can not be found! can someone help?

    How can I relocate songs from my Itunes? Itunes tells me that the original files can not be found! can someone help?

    punzete wrote:
    I can't do it that way. I erase these songs from the iTunes Library, but when I sycronize the iPhone, all these songs are copied again to the Library. Isn't there any way to stop that? Everything I buy on iTunes Store through my iPhone cannot be erased from the iPhone?
    WHY can't you do it the way 100 million people do it?

  • HT1386 Hi All, I plugged my iPhone into my laptop and I was asked to upgrade my iTunes software. It took more than seven hours and just to be told that my SIM card does not appear to be supported. Since then I can not use my iPhone. I am lost plse help. J

    Hi All, I plugged my iPhone into my laptop and I was asked to upgrade my iTunes software. It took more than seven hours and just to be told that my SIM card does not appear to be supported. Since then I can not use my iPhone. I am lost plse help. Jam53
    Every time I switch on the iPhone, the iTunes icon is displayed together with a USB icon and Emergency call message appears on the screen in many languages. When I touch the i symbol I get the following information IMEI: **** AND ICCID: ****
    However, the iphone is visible in the Devices directory in iTunes. I changed my SIM card but still can not be recognized by the iPhone.
    <Edited By Host>

    Do you mean when you say its locked to another carrier other then the one im using, that maybe my insurance sent me an iphone thats for a different network for example orange and not mine which is o2?

  • I need help! when I am importing my NEF files from my D3300 camera into lightroom 5 and try to use the "copy as DNG" button I always get an error message saying that "saying the file is not recognized by the raw format support"

    I need help! when I am importing my NEF Raw files from my D3300 camera into lightroom 5 and try to use the "copy as DNG" button I always get an error message saying that "saying the file is not recognized by the raw format support". The whole purpose of that button is so that the file can be recognized... How can I make the "copy as DNG" button work as it is supposed too?? Thank you

    Thank you for responding. So I essentially will never be able to use that button in lightroom 5? do I need to get LR 6? Will there ever be an update for LR 5 that will enable me to use it?
    Does DNG Converter work within LR or do I have to upload pictures to my computer and then make a second copy in DNG format. and then go into LR and use them?
    Thank you @dj_paige

Maybe you are looking for