'Regular expression to match all words in and including a given word
I'm looking for a regular expression (using JavaScript) to match all 3-6 letter words that contain all or some subset of the letters in a given word. For example, if my word is "rescue", then I should match "use", "cure", "reuse", "secure", and so on. What I have right now is:
\b(?!\w*(\w)\w*\1)[rescue]{3,6}\b
...And this works, but for the repeat letters. It won't match words with 2 e's:
r, e, s, c, u, e, should match at most 1 r, s, c, and u, with at most 2 e's.
Here I'm stuck. I'm not great at these things and it's a wonder I've come this far. This is not an operation I need to perform quickly or frequently, and the word list in only 20,000 words or so. I'm not concerned with the most efficient solution. I would love some help. Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

