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:
(^(?=.*\b(?i)The(?-i)\b)(?=.*\b(?i)service\(s\)(?-i)\b).*$)
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:
(?i)(?=.*\bThe\b)(?=.*\bservice\(s\)\B).*$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.