"John W. Krahn" schreef: > Dr.Ruud: >> John W. Krahn: >>> 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:]]? > > Oops, yes, I was wrong. :-) Not really, the \s did no harm, it was just extra. The space I am always concerned about is 0xA0: $ perl -wle '$_ = "\xA0"; /\s/ and print "s"' $ perl -wle '$_ = "\xA0\x{100}"; chop; /\s/ and print "s"' s This is because in Perl (5.8?) the first string is a Latin1 string, and the second a utf8 string. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/