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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Pattern matching for repeated pattern

 



kapila
New User

Apr 13, 2009, 10:09 PM

Post #1 of 2 (2553 views)
Pattern matching for repeated pattern Can't Post

Hi ,
I need to match a pattern something like this

$var="FILES CHECKED IN: TEST1 12.88 NONE TEST2 1.8 1.2 TEST3 1.9 1.6 ……so on"

pattern i wrote -
$pattern='FILES CHECKED IN:[\s]+(.*?)\s+(\d+\.\d+(\.*\d*)*)\s+(\d+\.\d+(\.*\d*)*|NONE)*'

This only matches the last pattern, i want it to match as many times its present. i.e
$1=TEST1
$2=12.88
$3=NONE
$4=TEST2
$5=1.8 so on..

means match repeatedly..can anyone help me in this?


1arryb
User

Apr 15, 2009, 8:34 AM

Post #2 of 2 (2524 views)
Re: [kapila] Pattern matching for repeated pattern [In reply to] Can't Post

Hi kapila,

Not sure what you're asking for, but:

If you are looking for all of the words after "FILES CHECKED IN: ", try:

Code
... 
$var =~ s/FILES CHECKED IN: //;
my @files = split(/\s+/, $var);

You only need tricky regular expressions if any of the "words" contain embedded whitespace.

Cheers,

Larry

 
 


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

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