Generate all possible maches from a regular expression.

  • Thread starter Thread starter mac.speed
  • Start date Start date
M

mac.speed

Hi!
i have set of over 100+ regular expressions, instead of checking user
input against these regex i want to store all possible matches in a
database and search against them.

like if a regex is
"what is your (home|office|cell|mobile) phone number"
will match against
1. what is your home phone number
2. what is your office phone number
3. what is your cell phone number
4. what is your mobile phone number

i want to generate this list from the above mentioned regex.
pls. guide.

regards
Mac
 
thanks for replying!

pls. read the problem again...i want to generate the possible matches
from regex...means i want to generate all sentences which will match
against the given regex.
 
Hi!
i have set of over 100+ regular expressions, instead of checking user
input against these regex i want to store all possible matches in a
database and search against them.

I don't believe there is any built-in way of doing this. A very quick
google doesn't turn up anyone who's done this already. The theory is
straightforward enough: create the matching finite state machine, then
recursively enumerate everything it produces. Maybe looking for some
online CS course notes might produce something.

btw, what do you want to return if the input regex is "a+" ?
 
Hi!
i have set of over 100+ regular expressions, instead of checking user
input against these regex i want to store all possible matches in a
database and search against them.

like if a regex is
"what is your (home|office|cell|mobile) phone number"
will match against
1. what is your home phone number
2. what is your office phone number
3. what is your cell phone number
4. what is your mobile phone number

what is your [hocm][ofe][mflb][ile]* phone number
 
Back
Top