I am trying to validate via RegEx as follows ...
If Regex.IsMatch (Output, "B \" and "Serial)" & amp; "\ B") then 'there is some end if but I get this argument exception
parsing "\ bSerial) \ b" - lots of ) Of. I understand the error, but how do I modify the RegEx expression?
UPDATE The word "serial" dynamic It means I can get another exception for at least one more character for me.
Answers to 'bird and tanicus' correctly explains why your regex fails to compile .
But:
Even after avoiding brackets, be careful with your regex: \ b in only matches Word limits ( foo serial) will not match in the string like . It matches will foo serial) times , but only because \ b matches first Bar . Similarly, this string will not match the serial). .
In this way, it will not always be around a string with just \ b that you think
Foo serial) bar foo (serial) bar: Edit: If, according to your comment below, in the list below ... FU serial) Bar FU serial))) )) FU serial)
... should be only the first and fifth matches, I tell that the rule matches the whole word, only if
If Regex.IsMatch (Output, "(? & Lt; = ^ |) Use / first> or. \ S) "& amp; Regex.Escape ("Serial)") & amp;However, it will no longer match
foowithdoes not match.he said "foo"if you want to allow it, thenif Regex.IsMatch ("output," (? & Lt; = ^ | \ B | \ s) "and use Regex.Escape (" serial ") & Amp; "(? = \ S | \ b | $)") then... but it will now match the second example. Choose your weapon carefully :)
(Explanation:
(? & Lt; = | | \ b | \ s)is a positive perspective, which matches, string The beginning of a word boundary or the character of a white spot just before the current location, not adding anything to the outcome of the match.(? = \ S | \ b | $)Its lookimer equivalent Is.)
Comments
Post a Comment