473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Generate all possible maches from a regular expression.

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

Jan 18 '06 #1
5 1760
Use RegExMatches instead of RegExMatch

--
<ma*******@hotmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.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

Jan 18 '06 #2
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.

Jan 18 '06 #3

ma*******@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

Jan 18 '06 #4
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.rezea...htm#Generating

but it is not of much help.

anybody ?

Jan 18 '06 #5

<ma*******@hotmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.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

Jan 18 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chris Lasher | last post by:
Hello, I would like to create a set of very similar regular expression. In my initial thought, I'd hoped to create a regular expression with a variable inside of it that I could simply pass a...
1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
4
by: Buddy | last post by:
Can someone please show me how to create a regular expression to do the following My text is set to MyColumn{1, 100} Test I want a regular expression that sets the text to the following...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
11
by: vbgunz | last post by:
Hello all, I am just learning Python and have come across something I feel might be a bug. Please enlightenment me... The following code presents a challenge. How in the world do you provide an...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
5
by: davehansen22 | last post by:
Is there a way to generate a MySQL WHERE clause from a search string like this: "(dave OR hansen) php programmer" I would want to use the generated MySQL clause against a "memo" type field. ...
4
by: MZ | last post by:
Hello! I have got URL address like this: http:\\www.ZZZZ.com?param=10 Is it possible to call and read the GET param parameter value in Javascript? I mean such code in PHP language:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.