good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: 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 reply to Re: regexp - repeatedly delete words expressed in alternation from end of string
by ikegami
|
|