Perl - Generate All Matching String To A Regex

data-generation, perl, regex

Solution

No there is no way to generate all matches for a certain regex. Consider this one:

a+

There is an infinite number of matches for that regex, thus you cannot list them all.

By the way, I think you want your regex to look like this:

05[0247]\d{7}

Problem

I am kinda new in perl, i wanted to know if there is a way for generating all the combinations that matches a regex. how is the best way to generate all the matching strings to : ``` 05[0,2,4,7][\d]{7} ``` thanks in advance.

Original source