How do I write a .net regex which will match a string that does NOT start with "Seat"
+7
A:
Writing a regex for a "does not start with" can be a little tricky. It's often easier to write a regex to detect that a string starts with a substring and not the match instead.
For Example:
return !Regex.IsMatch("^Seat.*", input);
JaredPar
2009-01-08 16:35:31
Yay for that answer. I like keeping things simple.
PEZ
2009-01-08 18:34:39
A:
I would suggest not doing it. You should be able to just get every string that doesn't match.
!Regex.IsMatch("^Seat.*", string);
Samuel
2009-01-08 16:37:16