Re: Regexp non-alphanumerics to spaces
- From: rob.dixon@xxxxxxx (Rob Dixon)
- Date: Fri, 30 Mar 2007 20:29:24 +0100
Grant wrote:
Hello, can you guys show me how to convert each non-alphanumeric
character in a string to a space, and then convert any number of
consecutive spaces in the string to a single space?
If I need to specify exactly which characters I want converted to
spaces, I'd be happy with just the "." character.
Hi Grant.
$text =~ s/[^[:alnum:]]/ /g;
$text =~ s/\s+/ /g;
will do what you want.
Rob
.
- Follow-Ups:
- Re: Regexp non-alphanumerics to spaces
- From: John W. Krahn
- Re: Regexp non-alphanumerics to spaces
- From: Grant
- Re: Regexp non-alphanumerics to spaces
- References:
- Regexp non-alphanumerics to spaces
- From: Grant
- Regexp non-alphanumerics to spaces
- Prev by Date: Regexp non-alphanumerics to spaces
- Next by Date: Re: www::mechanize question
- Previous by thread: Regexp non-alphanumerics to spaces
- Next by thread: Re: Regexp non-alphanumerics to spaces
- Index(es):
Relevant Pages
|