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?
The regular expression pattern to identify in the text. In . NET, regular expression patterns are defined by a special syntax or language, which is compatible with Perl 5 regular expressions and adds some additional features such as right-to-left matching.
In C#, Regular Expression is a pattern which is used to parse and check whether the given input text is matching with the given pattern or not. In C#, Regular Expressions are generally termed as C# Regex. The . Net Framework provides a regular expression engine that allows the pattern matching.
By default, the comparison of an input string with any literal characters in a regular expression pattern is case-sensitive, white space in a regular expression pattern is interpreted as literal white-space characters, and capturing groups in a regular expression are named implicitly as well as explicitly.
A regular expression is a pattern that could be matched against an input text. The . Net framework provides a regular expression engine that allows such matching. A pattern consists of one or more character literals, operators, or constructs.
You're looking for the Regex.Matches
method (plural), which returns a collection containing all of the matches in the original string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With