Avatar of Misha
Misha
Flag for Russian Federation

asked on 

C# Regex

Hello!

I need find some substring in string. There are NOT letter symbols before and after this substring. Also there are begin and end of string near this substring.

For example, I need find "qwe" in  next cases:
1) " qwe "
2) "+qwe("
3) " qwe"
4) "qwe("
5) "qwe"

And NOT find "qwe" in case "qwer"
I try this regex:

[^a-zA-Z](qwe)[^a-zA-Z]

Open in new window


This regex can not find "qwe" in 3,4 and 5 case .
How add symbols begin and end of string in [ ???]
Regular ExpressionsC#

Avatar of undefined
Last Comment
Terry Woods

8/22/2022 - Mon