in reply to Replacing symbols in a string
Depending on the encoding your string is in, the easiest is to use either \W (for ASCII) or [[:^alpha:]] (for Unicode?). See perlop on the s/// operator and perlre on the character escapes used.
s/\W/ /g;
Update: Fixed incorrect usage of POSIX character class, as spotted by AnomalousMonk. It's [[:alpha:]], and not [:alpha:] (this error is also mentioned in perlre, and will produce a warning, while matching :, a, l, p or h.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Replacing symbols in a string
by JavaFan (Canon) on Jul 16, 2011 at 17:59 UTC | |
|
Re^2: Replacing symbols in a string
by AnomalousMonk (Archbishop) on Jul 16, 2011 at 17:45 UTC |