in reply to pcre regex
Show us some sample data that fails and some test code. If the problem is real you shouldn't need more than a few lines of data and a few lines of code to reproduce the problem.
Are you sure the pattern you want to match is at the start of the line? Could it be that you are reading the entire file into a string and are then trying to match against that string? If so you probably need to use the m (multiple line match) switch. Consider:
use strict; use warnings; my $str = <<TEXT; First line 1234X last line TEXT print "Matched\n" if $str =~ /^\d{4,4}[A-Z0-9]$/; print "Multi-matched\n" if $str =~ /^\d{4,4}[A-Z0-9]$/m;
prints:
Multi-matched
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pcre regex
by Anonymous Monk on Apr 06, 2012 at 10:41 UTC |