3

The regular expression /^[a-z]*$/ is a quick way to match against all characters in the range.

But how can I remove a group of characters from that range?

For instance, what regular expression matches against a-z with e,o,u excluded?

Of course, I can manually put the multiple ranges but I wonder whether there is any better way?


EDIT. A similar but more broad question did not refer to JavaScript. However, JavaScript has a special treatment of regular expressions, see here for instance. Many expressions from other languages do not work in JavaScript, so I feel a separate more specific JS questions deserves some merit.

Community
  • 1
  • 1
Dmitri Zaitsev
  • 13,548
  • 11
  • 76
  • 110
  • 1
    `/^(?:(?![oeu])[a-z])*$/` I believe, based on the answers there... A negative lookahead and the character class, grouped together with a non-capturing group, repeated zero or more times. – T.J. Crowder Apr 18 '17 at 08:57
  • 1
    @T.J.Crowder Thanks! It would be hard to dig that among all those answers, many of which do not work in JS. – Dmitri Zaitsev Apr 18 '17 at 09:17

1 Answers1

1

Putting the answer here so that this question doesn't show as unanswered:

/^(?:(?![oeu])[a-z])*$/

Credit goes to T.J. Crowder

Uniphonic
  • 845
  • 12
  • 21