in reply to regex search and replace globally
your regex is capturing to much to fast. This is better:
update:#!/usr/bin/perl -w use strict; use warnings; my $default_from_domain = 'www.domain.com'; my $unsub = 'un-foo@foo.com un-foo@foo.com'; print $unsub, "\n"; $unsub =~ s/(un-[^\@]+)\@[^ ]+/$1\@$default_from_domain/g ; print $unsub;
So far you have the following then: $1 contains "un-foo@foo.com un-foo" and $2 contains "foo.com". Anyhow since it captures the whole string right of the bat it will not find another match.
-enlil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: regex search and replace globally
by hv (Prior) on Apr 30, 2003 at 03:09 UTC | |
|
Re: Re: regex search and replace globally
by Anonymous Monk on Apr 30, 2003 at 17:14 UTC |