Simple regex negation -
Trying to match only the first letter in the sample below.
Sample String: C / C ++ / Objective Objective-C / Objective-C / Objective-C
My faulty regex: ( ?! [OO] Bjktiv [| -]?) C (?! \ + \ +)
Doh
Try it out:
(? & Lt ;! ]
...
- Negative lookhead (
Use negative attitudes instead of code> (? & Lt;!
)
bit)
[
... ]
bits. Also add Can be worth \ b
s has been added from both sides of C
, because your current regex coconut
, BBC < / Code>,
cfml
and so on
Also it is worth pointing out that inside the character classes, -
is special If not the first or last character. Some people also survived in these situations Not like, ie [\ -]
, if then after characters added by mistake.
Comments
Post a Comment