in reply to Re^3: Parsing Regex
in thread Parsing Regex
Results:$line =~ m/(.*?)(\d+\/\d+\/\d+)?\s*(.*)/; print "Input : $line"; print "Output \$1: -$1-\n"; print "Output \$2: -$2-\n"; print "Output \$3: -$3-\n\n";
I included the "neat" flag (x), but decided to take it away. For all purposes, the above should be the same. Note: I put the first "ungreedy capture anything" (.*?) in $1 for debugging purposes. The results are interesting.Input : 301 S. MAPLE STREET Output $1: -- Output $2: -- -utput $3: -301 S. MAPLE STREET Input : 09/09/2009 301 S. MAPLE STREET Output $1: -- Output $2: -- -utput $3: -09/09/2009 301 S. MAPLE STREET
Input : 301 S. MAPLE STREET Output $1: -000001- -utput $2: - JOHN SMITH, III Output $3: -- Input : 09/09/2009 301 S. MAPLE STREET Output $1: - - Output $2: -09/09/2009- -utput $3: -301 S. MAPLE STREET
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Parsing Regex
by deMize (Monk) on Sep 23, 2009 at 14:56 UTC |