in reply to Regex failing when the line starts with "./"
Maybe the faulty line should read as follows:
my( $value ) = $line =~ m{(?:\.\\|\./)(.*);};
(Re updated to correct the order of dot and slash)
Match either '.\' or '/.' followed by everything up to and including ';'. Note, I used '{' and '}' curly brackets to improve legibility. It's bad enough with all those \'s and /'s. I also used non-capturing (?:....) brackets in constraining the alternation so that the capturing brackets used later on in the same RE would retain their position as $1.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex failing when the line starts with "./"
by elef (Friar) on Feb 03, 2011 at 10:53 UTC | |
by Anonymous Monk on Feb 03, 2011 at 12:33 UTC | |
by Anonymous Monk on Feb 03, 2011 at 12:36 UTC | |
by Anonymous Monk on Feb 03, 2011 at 14:07 UTC |