Like hippo, I don't really understand the questions(s) you're asking in the OP, and I agree with his or her recommendations here. That said, I can hazard an answer based on part of your post:
The exclusion of an entire word, not just characters ...
I think what you may be asking for is an alternative to [^somechars] (an inverted character class) in an [^somechars]* expression that will generalize to any pattern. Something like this may fill the bill:
The (?: (?! $pattern) .)* sub-pattern matches "zero or more of any character so long as the character is not at the start of something matching $pattern." Contrast with the behavior ofc:\@Work\Perl\monks>perl -wMstrict -le "my $pattern = qr{ \b f[eio]e \b }xms; ;; my $str = 'foo bar feeble macfee unfeeling fee fumble'; ;; print qq{match: '$1'} if $str =~ m{ (bar (?: (?! $pattern) .)* f \w+) + }xms; " match: 'bar feeble macfee unfeeling fee'
Update: As a parenthetic note, the example above can be extended to show regex composition:
Again, contrast with m{ (bar $not_giant*? f \w+) }xmsc:\@Work\Perl\monks>perl -wMstrict -le "my $giant_sez = qr{ \b f[eio]e \b }xms; my $not_giant = qr{ (?! $giant_sez) . }xms; ;; my $str = 'foo bar feeble macfee unfeeling fee fumble'; ;; print qq{match: '$1'} if $str =~ m{ (bar $not_giant* f \w+) }xms; " match: 'bar feeble macfee unfeeling fee'
Give a man a fish: <%-{-{-{-<
In reply to Re: String replace - Part II
by AnomalousMonk
in thread String replace - Part II
by kepler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |