in reply to Re: stripping characters from a string
in thread stripping characters from a string
Good post. Here's what I would do if all I wanted was your last result:
# note the lower-casing inline ($fus = lc $fus) =~ s/\W+/_/g; #all spans of 1 or more non-words becom +e 1 '_' $fus =~ s/^_|_$//g; #at most one on each end, because of th +e above
But, for the poster's question, removing all single-quotes and migrating spaces to _...
for ($string) { s/\s+/_/g; #convert 1+ spaces to a single '_' s/'|^_|_$//g; #trim lead/trail _ and remove single quotes }
Which is going a bit further than the direct solution of
$string =~ tr/\s'/_/d;
|
|---|