Well, to just get the message and email address in a naive way you could do (untested)
my ($message,$email)=m{^-S\s* "([^"]*)" \s* (.*)}x;
BUT this way you don't allow any escaped " in your message string. i.e. something like "hi, that \" char is difficult". If you change [^"]* to .* then it would allow escaped ", but then you would get into trouble if the email address had any " char in it, for example "John Doe" <doe@wo.com>.
Also note there is no real checking if the email address comforms to any email address standard. If you only expect doe@wo.com style addresses, that could be parsed with something like [^@]+@[^@]+, but to parse any valid email address you should use a module like Mail::Address.
If you get this line from unknown sources, there are more things to consider, depending on what you want to do
In reply to Re: Regular Expression problem
by jethro
in thread Regular Expression problem
by himanshu.padmanabhi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |