in reply to Re: Make a variable safe for a regex.
in thread Make a variable safe for a regex.
That printsmy $str = join '', map chr, 0 .. 255; my $qm = quotemeta( $str); ( my $kyle = $str) =~ s/(\W)/\\$1/g; my $quoted_qm = join '', $qm =~ /\\(.)/g; my $quoted_kyle = join '', $kyle =~ /\\(.)/g; printf "quotemeta: %d, kyle: %d (%s)\n", length $quoted_qm, length $quoted_kyle, $quoted_qm eq $quoted_kyle ? "same" : "differernt";
Annoquotemeta: 192, kyle: 192 (same)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Make a variable safe for a regex.
by diotalevi (Canon) on Feb 26, 2007 at 00:47 UTC | |
by Anno (Deacon) on Feb 26, 2007 at 08:32 UTC |