I think my requirement was not clear.
I need to get third field from the string.
For example, my string is: "MACROBUTTON AbaisserEnCorpsDeTexte \"[Click here and insert a PICTURE (mandatory)]\""
and third field from this string is “[Click here and insert a PICTURE (mandatory)]”
I do not want to extract string between “” This third field can be anything. This is just en example.
Another examples of strings are: "MACROBUTTON AbaisserEnCorpsDeTexte ..." "MACROBUTTON CheckFail PASS" etc.
In above examples, third fields are “…” and “PASS”
(1) If your string is really a record of a sort, with space-separated fields, and each field is either no-white-space, or if it has whitespace, is double-quoted, AND if the number of fields is FIXED, I would suggest you use Pcre (or Str) and write a regexp with capture groups (the parentheses). That’ll get you whichever field you wish.
(2) If the above is true, except that the # of fields is unbounded, then you’ll probably need to write something that iterates down the string to the field of interest. You can do that with Pcre again, since you can do a match from a starting-position.
This will require that you carefully specify the syntax of fields. So for instance, if the double-quoted field can itself contain escaped double-quotes, you’ll need to make sure your regex accounts for that.
If you’re working on a lot of problems like this, I think learning how to use regular expressions is going to be really, really valuable. And this will be true regardless of which language you choose: indeed, in perl/python/ruby/etc, you’ll need them even moreso than in Oaml.
the regexp you cite is an attempt to match the -separator- between fields. But that separator appears in fields. I’d suggest you first write a regexp to match a field, and then string them together with the regexp to match the separator. What is a regexp that matches the entire line?
At this point, it might be useful to back up and work thru the lexical analysis chapter in a good compilers textbook, and/or the O’Reilly book on regexps.