perlpal has asked for the wisdom of the Perl Monks concerning the following question:
I need to perform multiple operations on a string
- remove special characters like (% ,(,),*)
- replace continuous white spaces with a single underscore
- replace all uppercase letters with lowercase letters
Currently , i have written the following code snippet to accomplish the same
$string =~ s/ \(.*\)//g; $string =~ s/ {1,}/_/g; $string = lc ($string);
Is there a more optimized approach for the same?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex operation optimisation
by jethro (Monsignor) on Jul 02, 2010 at 09:57 UTC | |
by number2 (Initiate) on Jul 02, 2010 at 11:12 UTC | |
by oldmanwillow (Novice) on Jul 02, 2010 at 12:31 UTC | |
by JavaFan (Canon) on Jul 05, 2010 at 10:40 UTC | |
|
Re: Regex operation optimisation
by jwkrahn (Abbot) on Jul 02, 2010 at 12:31 UTC | |
by marinersk (Priest) on Jul 02, 2010 at 21:39 UTC | |
by jwkrahn (Abbot) on Jul 02, 2010 at 23:36 UTC | |
by marinersk (Priest) on Jul 06, 2010 at 21:05 UTC |