
Alvaro
Novice
Apr 29, 2011, 1:50 PM
Post #1 of 13
(1240 views)
|
|
Can't get the $1 and $2, but regex works fine with Reggexbuddy
|
Can't Post
|
|
Hello, I can't make this script work, but the regex is ok as I checked it on regexbuddy. Seems it's not passing the $1 and $2. If I put only one regex and only place $1) it works fine, but can't make the two work. ((?<=')\W*[0-9]*(?=') or (?<==)[a-z0-9]*(?=') alone works just fine. ================ #!C:\Perl\bin\perl.exe use English; use strict; use warnings; use locale; open (FILE, "<aname.txt"); open (FILE1, ">>aname_result.txt"); while (<FILE>) { my($line) = $_; chomp($line); if (my($word) = $_ =~ m/((?<=')\W*[0-9]*(?='))((?<==)[a-z0-9]*(?='))/) { print "$1;$2;\n"; } # else # {print "Nothing\n";} } close (FILE); close (FILE1); ==============
|