I am attempting to expand on this regex for listing all possible anagrams for a given set of letters:
^(?!.*([aer]).*\1)(?!(.*d){4})([aerd]*|[a-z])$
so far based on this regex, I can receive a match on any combination of words and sub-words made up of the letters 'dadder', such as 'adder', 'add', 'ad', 'red' etc. The reason for the regex complexity instead of a simple [dadder]*
is because obviously each letter can be matched an infinite amount of times, which is bad, I want each letter to match the test string only once, if two d's are provided, it can match up to two times only or less. If somebody of course could streamline the regex to match any combinations of letters exactly X times specified, please feel free to provide it :)
However my main question, I would now like to incorporate a full stop character ".". If a full stop is ever encountered in the list of characters, it acts as a wildcard and could match any character a-z. So dadd.r
could match daddzr
, daddor
, daddpr
, rpdadd
etc.
Could anybody help me with this?