Need help on Regex

Splash Forums PrettyFaces Users Need help on Regex

This topic contains 1 reply, has 2 voices, and was last updated by  Christian Kaltepoth 9 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #18870


    I want to split the string : “FNAME,”STREET,PLACE”,ADDR2,XYZ”

    Desired O/p : (Comma seperated values but ignore the , when it is between “”)





    I seach on internet and find : “,(?=([^”]*”[^”]*”)*[^”]*$” this regex working fine for me but I am not able to understand this. Also please suggest if there is any better way of doing this.

    Thanks in Advance


    I’m not sure if you should use regular expressions in this case. This really gets complicated.

    The format you are trying to parse looks a lot like CSV. There are many free libraries out there that can parse CSV files. Perhaps you should check if there is any library that fits your needs.

    But you could also do the parsing yourself. This should be very easy if you read character by character. Whenever you hit a ", switch into some kind of string-literal mode. If you find a , and are not in string-literal mode, you found a new column. That’s just a simple state machine. :)

Viewing 2 posts - 1 through 2 (of 2 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.