Hi all. I'm trying to craft a regular expression to help me tokenize a string
containing mixed content. The string would be something like:
foo "bar baz" fuz
or another variant thereof. What I'm trying to accomplish is to use a RegEx
and get the following out of the above string:
foo
bar baz
fuz
However, I can't seem to figure out what I should use as a regular
expression to acheive the desired result. I'm also thinking that it might not
be possible to do this easily with a regex, in which case I'll just fall back
to manually breaking up the string. However, any insight would be appreciated.
Thanks!
Corey Snow
Niki Estner - 12 Oct 2004 22:52 GMT
> Hi all. I'm trying to craft a regular expression to help me tokenize a
> string
[quoted text clipped - 17 lines]
> to manually breaking up the string. However, any insight would be
> appreciated.
Will this expression work?
("[^"]*")|(\w*)
It seems to do so in Expresso.
Niki
Corey Snow - 12 Oct 2004 23:49 GMT
> > Hi all. I'm trying to craft a regular expression to help me tokenize a
> > string
[quoted text clipped - 24 lines]
>
> Niki
The expression ("[^"]*")|(\s*) does seem to work- with the "\w", it leaves
out any tokens outside the quotation marks.
Thanks!
Niki Estner - 14 Oct 2004 13:03 GMT
>> > Hi all. I'm trying to craft a regular expression to help me tokenize a
>> > string
[quoted text clipped - 29 lines]
> The expression ("[^"]*")|(\s*) does seem to work- with the "\w", it leaves
> out any tokens outside the quotation marks.
You must be using Regex.Match wrong then...
Matching for "\s" will only match for the spaces between words.
Niki