in reply to regex meaning
Replacing the number starting with one or more zeros and followed by a number with none. Here (?=\d), is positive look ahead which has zero width assertion. So it ll replace only the zeroes and not the following number.
Take a look at perlre and YAPE::Regex::Explain
For example:
$str = '004asdfsa'; #string starting with zero and followed by numbers $str =~ s/^0+(?=\d)//; print $str; Output: -------- 4asdfsa
$str = 'a004asdfsa'; #not starting with zero $str =~ s/^0+(?=\d)//; print $str; Output: -------- a004asdfsa
$str = '0a4sdfsa'; #no number followed by zero $str =~ s/^0+(?=\d)// ; print $str; Output: -------- 0a4sdfsa
Prasad
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: regex meaning
by bart (Canon) on Nov 12, 2007 at 15:03 UTC | |
Re^2: regex meaning
by hashin_p (Initiate) on Nov 12, 2007 at 11:11 UTC |