geektron has asked for the wisdom of the Perl Monks concerning the following question:
i reduced the regex-matching to a minimal test script and commented the regex. it works in the test script but not in the real one.
here's the test case:
and that *works*! when i apply the same regex in the real script ( cut-n-paste between windows) it fails to match. the only differences:my $string = ' 5954 Bluebonnet Sun Catcher Horizontal Oval 6"X9" +1 @ $ 39.95 = $ 39.95 '; my $string2 = '5422 Texas Home Luggage Tag 6 @ $ 3 +.95 = $ 23.70'; + + + + + + + print " 1 set to $1\n match \n\n" if ( $string2 =~ /([\d]+) # match first digits ( greedy ) \s+ # multiple space ([\w\s|"|\-|\']+) # capture at word boundary \s{2,} # single space followed by multiple spaces ([\d,\.]+) # capture digit, comma, period \s\D+ # single space, non-digit character ([\d,\.]+) # capture digit comma period \s\D+ # space plus non-digit character ([\d,\.]+) # capture digit comma period /ix # end regex ) ;
etc.my $prodID = $1; my $prodDescr = $2;
i've been banging my head on this and getting nowhere FAST. i've looked for hidden chars in the real file ( vi's 'set list' mode ) and found no differences. any clues as to where i should be looking?
added some cleanup. thx Roy Johnson
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex matching problem
by Roy Johnson (Monsignor) on Jan 20, 2004 at 17:47 UTC | |
by geektron (Curate) on Jan 20, 2004 at 18:01 UTC | |
by geektron (Curate) on Jan 20, 2004 at 18:19 UTC | |
by Roy Johnson (Monsignor) on Jan 20, 2004 at 19:00 UTC | |
by geektron (Curate) on Jan 20, 2004 at 21:17 UTC | |
|
Re: regex matching problem
by ysth (Canon) on Jan 20, 2004 at 18:16 UTC | |
by geektron (Curate) on Jan 20, 2004 at 18:32 UTC | |
|
Re: regex matching problem
by Theo (Priest) on Jan 20, 2004 at 18:25 UTC |