0

How to create a regex that matches characters which contain at least one of each of the {"e","t","l","a","b"}?

So for example if I run it on an English dictionary, it will produce words like

  • aberrational
  • blabbermouths
  • table
  • tablespoonful
user13892
  • 267
  • 4
  • 12
  • chaining multiple lookahead assertion for each character works but it makes the regex too long is there a way to shorten the following regex? `(?=.*e)(?=.*t)(?=.*l)(?=.*a)(?=.*b).*` – user13892 Apr 17 '20 at 22:52
  • There's no other way AFAIK (except if you project to write all permutations). But you don't have to worry about pattern length, you have to worry about pattern efficiency: for that replace each `.*` using an approptiate character class like `(?=[a-df-z]*e)...` and start your pattern with a word boundary. – Casimir et Hippolyte Apr 17 '20 at 23:01

0 Answers0