in reply to Regex substitution problem
$to_email =~ s/.+To:\s(.+?)xxx.*/\1/;
In addition to the non-greediness change suggested by jethro, you'd also need a trailing .* to match the remainder of the line, because only what matched will be subsituted.
Also, you'd need to take care that the 'xxx', which you use to locate the end of the mail address, will not itself be part of the mail address. (Not sure of how much relevance that potential problem is here, so as a quick fix, I simply changed .*? into .+? — the .+ consumes one of the x'ses, so the first occurrence of 'xxx' will no longer be a candidate for the terminating 'xxx'...)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex substitution problem
by mahira (Acolyte) on Feb 14, 2009 at 14:04 UTC |