That is okay, I dont want to do that way. I want to write stronger regular expressions. I would like to know if my regular expressions are correct. further, when I write something like /((a|A)(b|B))/g For aB I am getting, $1 = aB, $2 = a, $3 = B. and $4,5,6 .. have the next occurrences. But I do not want a or B, only aB's. I cannot remove inner parentheses as it would be /(a|Ab|B)/ which is not what I want. Is my problem clear?
>From: Timothy Johnson <[EMAIL PROTECTED]> >To: "'Rum Pel'" <[EMAIL PROTECTED]>, [EMAIL PROTECTED] >Subject: RE: grouping regex match return values >Date: Wed, 18 Sep 2002 01:06:57 -0700 > > >How about this? > >while($_ =~ /(\d{1,2}\/\d{1,2}\/\d{4})/g){ > push @q,$1; >} > >Perl assigns the variable $1 to the first match in parentheses. ($2 for the >next match within the same regex, and so on) > > >The regex above matches: > > One or two digits \d{1,2} > followed by > a backslash \/ > followed by > one or two digits \d{1,2} > followed by > a backslash \/ > followed by > four digits \d{4} > >-----Original Message----- >From: Rum Pel [mailto:[EMAIL PROTECTED]] >Sent: Tuesday, September 17, 2002 9:18 PM >To: [EMAIL PROTECTED] >Subject: grouping regex match return values > > > >I want to pick dates from a file, I did it the following way: >----- >$day = "([12]?[0-9]|30|31)"; >$weekday = "(Mon|Tue|Wed|Thu|Fri|Sat|Sun)"; >$month = >"([1-9]|10|11|12|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"; >$year = "(1999|2000|2001|2002)"; > >$query = "$month\/$day\/$year"; > >@q = "Today is Tue 9/17/2002 Tomorrow is 10/17/2002?" =~ /$query/g; >print "q = " . Dumper(@q); >----- > >Now, the array q has 6 values - 9, 17, 2002, 10, 17, 2002. >Instead I want two values only - "9/17/2002", "10/17/2002" > >do i need to rewrite my query? > > > > >_________________________________________________________________ >MSN Photos is the easiest way to share and print your photos: >http://photos.msn.com/support/worldwide.aspx > > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]