Need a specific Regular Expression

Need a specific Regular Expression

Post by Q29yZXkgU2 » Thu, 14 Oct 2004 01:55:29


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
 
 
 

Need a specific Regular Expression

Post by Niki Estne » Thu, 14 Oct 2004 06:52:59

"Corey Snow" <Corey XXXX@XXXXX.COM > wrote in


Will this expression work?
("[^"]*")|(\w*)

It seems to do so in Expresso.

Niki

 
 
 

Need a specific Regular Expression

Post by Q29yZXkgU2 » Thu, 14 Oct 2004 07:49:08


The expression ("[^"]*")|(\s*) does seem to work- with the "\w", it leaves
out any tokens outside the quotation marks.

Thanks!
 
 
 

Need a specific Regular Expression

Post by Niki Estne » Fri, 15 Oct 2004 21:03:13

"Corey Snow" < XXXX@XXXXX.COM > wrote in




You must be using Regex.Match wrong then...
Matching for "\s" will only match for the spaces between words.

Niki