I am trying to create a regex expression which will allow the test string to match with the following conditions:
- The test string can be any length and contain any letters.
- ALL characters in the regex must be matched.
- All letters in regex must be matched ONLY the number of times they are repeated in the regex expression.
- If a letter is repeated more than once in the regex it can be consecutive in the test string or separated by other letters.
- The letters in the test string don't have to be in the same order as the regex.
So if:
TEST STRING = polymmorphiiic
the following regex would match
ppy
ooyc
ciii
whereas the following would fail:
pmy
iy
yrz
Your help appreciated as I can get all the above satisfied.
I have tried breaking down all the requirements and creating regex string for each but I can't get over string that will cover all.
source https://stackoverflow.com/questions/76349191/regular-expression-that-matches-only-the-letters-in-a-given-word
Comments
Post a Comment