CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions:
Finding Amount of digits Matching


New User

Sep 13, 2007, 1:40 AM

Post #1 of 4 (7578 views)
Finding Amount of digits Matching Can't Post

Hi,I have the following problem.

Say i have a code 002577.

I want to match this agains a big number of regular expressions and find the best match.Say the best matches is the following.


My problem is that 002577 is less digits that all three these regular expressions.Thus something like

002577 =~ 002577[6-9][0-5] 
002577 =~ 00257795[5-9]
002577 =~ 002577[6-9][6-9]

does not match in any case.I would like my script to realize that the 002577 matches the first part of the regular expression and return me with the amount of digits matching.

I have a generel script that matches a lot of regular expressions(most the code i want match is longer than the regular expressions,so it works mostly,but in cases like the above i run into problems.)

Any idea how I can fix this.Any help will really be appreciated.



Sep 13, 2007, 8:59 AM

Post #2 of 4 (7573 views)
Re: [baddah] Finding Amount of digits Matching [In reply to] Can't Post

Your question and examples are not making sense to me.

New User

Sep 13, 2007, 9:11 AM

Post #3 of 4 (7572 views)
Re: [KevinR] Finding Amount of digits Matching [In reply to] Can't Post

HI,Thanks for the reply.

Sorry,i'll try to rephrase.I have a table of regular expressions(all represent phone numbers/codes).No i have a code,and i am traversing through the table and i want to find a match.
I want my script to give me back all matches for a code(002577 in this case).

002577 has 6 digits,so it must look for all regular expressions where the first 6 digits match.Thus 002577[6-9][0-5] will match because the first 6 digits of the regular expression are the same.(It must not look at the [6-9][0-5] part,because the code i'm looking for only has 6 digits)

00257795[5-9] and 002577[6-9][6-9] will match for the same reasons.Their first 6 digits match the code i'm looking for.(002577)

The script must just take the code(002577) and get the amount of digits(6) and look at the all the regular expressions i have in my table,but only the first 6 digits.

I hope this makes more sense,Please let me know if it does not.i really would appreciate help with this.



Sep 13, 2007, 9:26 AM

Post #4 of 4 (7570 views)
Re: [baddah] Finding Amount of digits Matching [In reply to] Can't Post

Let me see the table of regexps, maybe that will help me to undestand your question.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives