in reply to Re: Re: Re: Re: Turn Hate Mail to Love Letter: Regex Multi-Word/Phase Replace
in thread Turn Hate Mail to Love Letter: Regex Multi-Word/Phase Replace

AHHH! Finally I got the problem!

I forgot that you join all your keys to one regexp!

I have to admit that I never used Tie:RegexHash. So I have no experience with it. Tell us when you finally had success.

  • Comment on Re: Re: Re: Re: Re: Turn Hate Mail to Love Letter: Regex Multi-Word/Phase Replace

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Turn Hate Mail to Love Letter: Regex Multi-Word/Phase Replace
by chunlou (Curate) on Jun 26, 2003 at 10:20 UTC
    Regexp::Subst::Parallel seems to do the trick.
    use Regexp::Subst::Parallel; $_ = "Man Honoured at Harbour Centre by the Lift\n"; print; $_ = subst($_, qr/\b(h)arbour\b/i => '$1arbor', qr/\b(h)onour(.*?)\b/i => '$1onor$2', qr/\b(c)entre\b/i => '$1enter', qr/\b(L|l)ift\b/ => sub{$_=$_[1]=~/L/?"E":"e";$_."levato +r"} ); print; __END__ Man Honoured at Harbour Centre by the Lift Man Honored at Harbor Center by the Elevator