$to_email =~ s/.+To:\s(.*?)xxx/\1/;
will do what you want. The * is greedy which means it will take as much as it can. The '?' changes the * to a non-greedy version
In reply to Re: Regex substitution problem
by jethro
in thread Regex substitution problem
by mahira
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |