Sunday 15 April 2012

Regex with exception of particular words -


I have problems with regex; I need to create regex with the exception of a set of specified words, for example: Apple, orange, juice And these words are given, it will match everything except the above words apple (should not match) Applejus (match) Yamjis (match) delicious apple-juices (match) orange appellous (match) orange (should not match) juice (Match should not be) orange - apple-juice (match) apple-orange-apal (match) juice-juice-juice (match) orange-juice (match)

If you really want to do this with a regular expression, then you May seem helpful (especially negative attitudes in this example) Regenges written for Ruby (different syntax for some implementations are different):

  rx = / ^ (?! Apple $ | orange $ | juice $) /  

No comments:

Post a Comment