Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
A lot depends on what you want to "clean." For the specific case you mention (with all those naughty barewords... put on some quotes, or you'll catch a horrible illness), you might be able to employ the builtin character class \w ("word" characters) or its negation, \W (not "word" characters). The perldoc perlre can help a lot here. Since I can't tell exactly what you're trying to fix, I'll assume you want to get rid of any non-word characters at the end of the string, for which ought to suffice. The $ anchors the match to the end of the string, and "\W+" matches "one or more non-word characters". It then replaces any such pattern found with nothing. HTH I mistrust all systematizers and avoid them. The will to a system shows a lack of integrity -- F. Nietzsche In reply to Re: the end of a word
by arturo
|
|