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

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

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