egal has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
Could you please help with the following issue:
While searching for multiple patterns on the same string, search continues from previous successful match point in the string. Is this expected ? How to make each pattern search start from beginning of the string each time.
Thanks a lot!!
open (MYFILE, "< $dir_dump$file") || die "Could not read dump file\n +"; while (<MYFILE>){ $dumpbuf .= $_; } $dumpbuf =~ s/\s//gs; die "Not a valid file, Check output!" if $dumpbuf !~ m/\d/gs; #match + one die "File contains only zeros, Check output!" if $dumpbuf !~ m/[1-9] +/sg; #match two while ($dumpbuf =~ m/(\w)/gs) { print "==$1\n"; # prints characters after initial two matches }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex String
by AppleFritter (Vicar) on Jul 04, 2014 at 09:23 UTC | |
by egal (Initiate) on Jul 04, 2014 at 09:47 UTC | |
by AppleFritter (Vicar) on Jul 04, 2014 at 09:54 UTC | |
by SimonPratt (Friar) on Jul 04, 2014 at 10:15 UTC | |
by AnomalousMonk (Archbishop) on Jul 04, 2014 at 14:52 UTC | |
|
Re: Regex String
by CountZero (Bishop) on Jul 04, 2014 at 10:40 UTC | |
|
Re: Regex String
by AnomalousMonk (Archbishop) on Jul 04, 2014 at 14:27 UTC |