[Solved] Regular expressions : how to find [closed]


The regex itself, while ugly and inefficient, should work. You do need to assign the string you’re adding into the regex before building the regex, though. While we’re at it, let’s clean it up:

string tmprect = "gg_rct_MyReg1";
Regex regexObj = new Regex(@"^\s*set\s+" + tmprect + 
                           @"\s*=\s*Rect\s*\(\s*([^,\s]*)\s*,\s*([^,\s]*)\s*,\s*([^,\s]*)\s*,\s*([^)\s]*)\s*\).*$");

([^,\s]*) matches any number of characters except commas or spaces. That is more specific than .* which will match too much and force the regex engine to backtrack.

0

solved Regular expressions : how to find [closed]