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)

  • Pipe characters removed from the character classes ( [ ... ] 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

Popular posts from this blog

MySql variables and php -

c# - How can I find out if there are windows above a control? -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -