in reply to Re^3: Regex Question
in thread Regex Question

Mine does replace the slash when it has a digit on only one side. The logic is that the slash is replaced unless there is a digit on both sides. It is the OP's logic that will not replace a slash with a digit on either side.
for my $field ( map $_, 'C/O', '2/4', 'C/2', 'd/l', '2/', '/2') { print "$field..."; $field =~ s/ (?<!C(?=.O)) # Look back a character and make sure it's not C-so +mething-O from there (?<!\d(?=.\d)) # Make sure it's also not a digit-something-digit (?:\\|\/) # The something is a slash or backslash / & /xgi; print "$field\n"; }

Caution: Contents may have been coded under pressure.