in reply to Re: Regex Question
in thread Regex Question
Nope. It replaces the slash in "9\\9" even though it shouldn't.
$field = '9\\9'; print("[$field] => "); $field =~ s/(?<!\d) # not preceeded by digits (?:\\|\/) # back or forward slash (?!\d) # not succeeded by digits / & /xg; # replace with '&' (globally) print("[$field]\n"); $field = '9\\9'; print("[$field] => "); $field =~ s/ (?<!C) # not preceeded by "C" (?:\\|\/) # back or forward slash (?!O) # not succeeded by "O" | (?<!\d) # not preceeded by digits (?:\\|\/) # back or forward slash (?!\d) # not succeeded by digits / & /xg; # replace with '&' (globally) print("[$field]\n"); __END__ [9\9] => [9\9] [9\9] => [9 & 9]
|
|---|