1

This is a regex that matches everything i want to exclude, which is words like abba, trillion etc.

[a-z]*([a-z])([a-z])\2\1[a-z]*

Is there something like [^] which i can use in this situation?

prof chaos
  • 404
  • 3
  • 18
  • post some valid and invalid examples.. – Avinash Raj Jan 25 '16 at 09:23
  • Possible duplicate of [How to negate the whole regex?](http://stackoverflow.com/questions/2637675/how-to-negate-the-whole-regex) – h2ooooooo Jan 25 '16 at 09:23
  • 1
    The [*How to negate the whole regex*](http://stackoverflow.com/questions/2637675/how-to-negate-the-whole-regex) post explains the negative lookahead technique and an example of how to exclude a whole string match, but unfortunately, not how to exclude matching *whole words*. – Wiktor Stribiżew Jan 25 '16 at 09:29

1 Answers1

1

You can use

\b(?![a-z]*([a-z])([a-z])\2\1[a-z]*\b)[a-z]+\b

See regex demo (I think you need a case-insensitive modifier with this regex.)

Since you want to match words only, you need to use \b word boundary, and to exclude specific words, you need to use a negative lookahead anchored to the leading word boundary.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563