I'm looking for a method to assign variables with patterns in regular expressions with C++ .NET something like
String^ speed;
String^ size;
"command SPEED=[speed] SIZE=[size]"
Right now I'm using IndexOf() and Substring() but it is quite ugly
String^ speed; String^ size;
Match m;
Regex theregex = new Regex (
"SPEED=(?<speed>(.*?)) SIZE=(?<size>(.*?)) ",
RegexOptions::ExplicitCapture);
m = theregex.Match (yourinputstring);
if (m.Success)
{
if (m.Groups["speed"].Success)
speed = m.Groups["speed"].Value;
if (m.Groups["size"].Success)
size = m.Groups["size"].Value;
}
else
throw new FormatException ("Input options not recognized");
Apologies for syntax errors, I don't have a compiler to test with right now.
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