I have an input string:
str= "row1:=dep_id=1,salary<3000;row22:=dep_id=1,salary<3000; row33:=dep_id=5,salary>5000"
Regex pattern:
regex.Pattern = "row\d+:=(.*?);"
Output:
MatchCollectionItem: row1:=dep_id=1,salary<3000;
SubMatchItem: dep_id=1,salary<3000
MatchCollectionItem: row22:=dep_id=1,salary<3000;
SubMatchItem: dep_id=1,salary<3000
It does not return the last ("row33...") because it ends without ";".
I've tried a few variations for the pattern
regex.Pattern = "row\d+:=(.*?)[;$]"
regex.Pattern = "row\d+:=(.*?)[;|$]"
However, the result is the same.
How to "tell" the the regex to match everything ending with ";" OR the end of string?
I need regex solution only, please.
$inside of a character set gets treated as a literal dollar sign, not an end line anchor. You want(?:;|$)