Home All Groups Group Topic Archive Search About

Generate all possible maches from a regular expression.

Author
18 Jan 2006 9:59 AM
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

Author
18 Jan 2006 10:26 AM
Cyril Gupta
Use RegExMatches instead of RegExMatch

--
<mac.sp***@hotmail.com> wrote in message
Show quoteHide quote
news:1137578353.574860.46770@g14g2000cwa.googlegroups.com...
> 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
>
Author
18 Jan 2006 10:52 AM
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.
Author
18 Jan 2006 11:23 AM
Larry Lard
mac.sp***@hotmail.com wrote:
> 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+" ?

--
Larry Lard
Replies to group please
Author
18 Jan 2006 11:39 AM
mac.speed
thanks Larry!
yes i know it won't cover all the regex but i've finite number of regex
with finite possibilities only.
the whole point is to optimize the search.

i found
http://perso.wanadoo.fr/joseph.rezeau/eao/developpement/expandRegexpToString.htm#Generating

but it is not of much help.

anybody ?
Author
18 Jan 2006 5:50 PM
Homer J Simpson
<mac.sp***@hotmail.com> wrote in message
news:1137578353.574860.46770@g14g2000cwa.googlegroups.com...
> 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