Generate all possible maches from a regular expression.

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
 
M

mac.speed

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.
 
L

Larry Lard

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+" ?
 
H

Homer J Simpson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top