Re: Regexp non-alphanumerics to spaces
- From: rvtol+news@xxxxxxxxxxxx (Dr.Ruud)
- Date: Sat, 31 Mar 2007 01:03:26 +0200
"John W. Krahn" schreef:
Rob Dixon:
Grant:
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?
$text =~ s/[^[:alnum:]]/ /g;
$text =~ s/\s+/ /g;
$text =~ s/[[:^alnum:]\s]+/ /g;
Isn't \s already part of [[:^alnum:]]?
Alternative:
s/[_\W]+/ /g;
--
Affijn, Ruud
"Gewoon is een tijger."
.
- Follow-Ups:
- Re: Regexp non-alphanumerics to spaces
- From: John W. Krahn
- Re: Regexp non-alphanumerics to spaces
- References:
- Regexp non-alphanumerics to spaces
- From: Grant
- Re: Regexp non-alphanumerics to spaces
- From: Rob Dixon
- Re: Regexp non-alphanumerics to spaces
- From: John W. Krahn
- Regexp non-alphanumerics to spaces
- Prev by Date: Re: www::mechanize question
- Next by Date: Re: Regexp non-alphanumerics to spaces
- Previous by thread: Re: Regexp non-alphanumerics to spaces
- Next by thread: Re: Regexp non-alphanumerics to spaces
- Index(es):
Relevant Pages
|
|