How do I match alpahbet with roman symbol following with regular expressions.
I have got #!WSⅡ%^ WSⅡ ancient data =>(should match both WSⅡ)
I have got #!WSⅡ%^ @#WSⅡ WSⅡ ancient data =>(should match 3 times)
I have got AbWSⅡ WSⅡRR WSⅡ ancient data =>(should match 1 time) (AbWSⅡ WSⅡRR should not match)
I am using the following regular expression.
(?<![a-zA-Z0-9])(\\bWSⅡ\\b)(?=[a-zA-Z0-9]|)
Which is working for my all the cases except the above.
Note : Ⅱ is not II
Please help.
Thanks in advance
You can use
(?<![^\W_])WSⅡ(?![^\W_])
See the regex demo .
The regex matches
(?<![^\\W_])
- a negative lookbehind that matches a location that is not immediately preceded with a char other than a non-word and _
char (so it basically requires start of string or a non-word char or _
right before) WSⅡ
- a WSⅡ
word (?![^\\W_])
- a negative lookahead that matches a location that is not immediately followed with a char other than a non-word and _
char (so it basically requires end of string or a non-word char or _
right after).
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.