in reply to Re^2: Regex operation optimisation
in thread Regex operation optimisation
perlpal's example was $string =~ s/ {1,}/_/g; which matches a space character while your example $string =~ s/\s+/\_/g; uses the whitespace character class (\s) which matches "\t", "\r", "\n" and "\f" as well as the space character. In general, the tr/// operator is more efficient then the s/// operator so I try to use it when appropriate.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Regex operation optimisation
by marinersk (Priest) on Jul 06, 2010 at 21:05 UTC |