Thursday, August 14, 2008

Regular expressions: Remove last appearance of some element

If you want to match A, B and C but don't want C to be the last element you can do it using this regular expression:



[ABC]+(?<!C)





Note that [ABC]+ can be mutch more complex then this is.

No comments: