in reply to Efficiently create an IF/ELSE regex
If there are no other spaces:
use strict; use warnings; my @incoming = ( "AD\thomas", "MAIN\nancy", "FOO\randy", "nancy", ); my %whitespace = ( "\n" => "n", "\t" => "t", "\r" => "r", "\f" => "f", ); for (@incoming) { print "$_: "; s/(\s)/\\$whitespace{$1}/g; print "$_\n"; }
(stealing some code from above...)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Efficiently create an IF/ELSE regex
by jcrush (Acolyte) on May 01, 2015 at 19:51 UTC | |
by Anonymous Monk on May 01, 2015 at 20:16 UTC |