Groups | Blog | Home
all groups > dotnet sdk > october 2004 >

dotnet sdk : Need a specific Regular Expression


Corey Snow
10/12/2004 9:55:29 AM
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
10/12/2004 3:49:08 PM


[quoted text, click to view]

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

Thanks!

Niki Estner
10/12/2004 11:52:59 PM
"Corey Snow" <Corey Snow@discussions.microsoft.com> wrote in
news:0C47C5C9-597A-48BA-8A01-273915C50D17@microsoft.com...
[quoted text, click to view]

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

It seems to do so in Expresso.

Niki

Niki Estner
10/14/2004 2:03:13 PM
"Corey Snow" <CoreySnow@discussions.microsoft.com> wrote in
news:25FACE37-1AB1-4E83-B506-F07E1D561BD4@microsoft.com...
[quoted text, click to view]

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

Niki

AddThis Social Bookmark Button