Ashton Ashton - 2 months ago 5x
C# Question

Regex match parenthesis

I have the following string:

The service(s), foo bar

I have a regex that checks if the words 'The' and 'service(s)' are contained within the string. I'm supposed to escape the brackets with backslash, but it does not seem to work. I must use the logical structure of this Regex. Can you help me fix the escaping?

Not working:


Target language is C#.


Closing parenthesis in service(s) asserts that next immediate position is a non-word boundary. So you don't need last \b token since you possibly meant a non-word boundary \B. I don't think you need to set and unset case-insensitive modifier either: