Match words using a single letter set

If this problem were thinking about how I should do this, I play some dictionary games, and I want to combine the words in the set of dictionary words with 5 letters, which I tried something like this

\b[clagey]{5}\b

that's good, but it's a matching word like "eagle." The problem is that I want each letter c, l, a, g, e, y one instance to not be an "eagle" with double e.

+4
source share
1 answer

Try this regex:

\b(?:([clagey])(?!\S*\1)){5}\b

Click to demonstrate

Explanation:

  • \b - word boundary
  • ([clagey])- corresponds to one of the symbols - c, l, a, g, e, yand fixes it in group 1
  • (?!\S*\1) - , , 1,
  • {5} - 5
  • \b -
+4

Source: https://habr.com/ru/post/1694091/


All Articles