Does .NET Regex support global matching?

Posted by Dave on Stack Overflow See other posts from Stack Overflow or by Dave
Published on 2010-04-26T17:18:22Z Indexed on 2010/04/26 17:23 UTC
Read the original article Hit count: 367

Filed under:
|
|
|

I haven't been able to find anything online regarding this. There's RegexOptions, but it doesn't have Global as one of its options. The inline modifiers list also doesn't mention global matching.

In a nutshell, I've got a regex to parse something like

--arga= "arg1"  --argb ="arg2" 

into separate argument name/value pairs using this regex:

--(\\w+)\\s*=\\s*\"(\\w+)\"\\s*

but the .NET Regex class doesn't do it globally (iteratively). So in order for me to get this to work, I'd have to do a match, then remove this from the argument string, and loop over and over again until I've exhausted all of the arguments.

It would be nicer to run the regex once, and then loop over the match groups to get the name value pairs. Is this possible? What am I missing?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#