XP is just a number | |
PerlMonks |
Re: regexp - repeatedly delete words expressed in alternation from end of stringby ikegami (Patriarch) |
on Nov 06, 2007 at 16:33 UTC ( [id://649253]=note: print w/replies, xml ) | Need Help?? |
First, wouldn't it be better to start with a list of words instead of a regex?
So we'll need to build the regex programatically.
Using Regexp::List can greatly speed up the process.
Now that we have the regex, let's avoid the fragility of 1 while s/// while properly removing spaces.
Note: You were using capturing parens ((...)) when you only needed non-capturing parens ((?:...)). Removing the need to capture greatly improves the speed of regexs. Update: Oops, it could still leave spaces. Fixed.
In Section
Seekers of Perl Wisdom
|
|