"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."

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to