Reputation: 1547
I am using PCRE in PHP and I need to find a way to generate say an array of all possible matching values. Any ideas?
For example if I had R[2-9]{1}
I would want:
R2
R3
R4
R5
R6
R7
R8
R9
Upvotes: 1
Views: 296
Reputation: 21999
PCRE does not have the ability to generate sample strings based on a regular expression. I do not know of a PHP library that does. Libraries that can do this usually support only limited regex flavors and need artificial restrictions for regexes like R[2-9]*
that can match an infinite number of strings.
If you only need to do this for very simple regexes like R[2-9]
then it shouldn't be to hard to either:
Upvotes: 1