List Info

Thread: .NET regex for command line (so close)




.NET regex for command line (so close)
country flaguser name
United States
2007-08-23 16:13:51
I've seen several tutorials on looping through the arg list
and making
a dictionary of commandline options, but I figured it has to
be
possible in a single regex to parse each match in the
commandline and
still allow it to be robust.

this is what I have right now:

(?:[-|/]{1,2}(?<parameter>w+)[=|:|s]+(?:(?<quo
te>["']?)(?
<value>.*?)k<quote>))

This matches the following "comples" command
lines:
--param="value"
-param='value'
/param  : "value 'with subquote'"

but it's having a problem with the simple:
-param value
-param=value
-param: value

I've tried using:
(?:[-|/]{1,2}(?<parameter>w+)[=|:|s]+(?:(?<quo
te>["']?)(?<value>[^
k<quote>]*?)k<quote>))
but the .NET regular expression doesn't understand the named
match
inside the group exclusive [^] brackets...giving the error:
Unrecognized escape sequence k.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )