0

I am trying to extract a specific pattern from a string using a regular expression group. My pattern is

'*-to:' 'anything as a text but not an email' 'email'

eg.

send-to: Firstname Surname something@email.com

I am using

/(^.*-to:)(.*[^*@*])(\s[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4})/i

which works fine when the exact pattern is matched but if I get

send-to: Firstname Surname something@email.com somethingelse@email.com 

it returns both mails which is not the desirable result. How I could get only the exact matches of this specific pattern?

geoandri
  • 2,360
  • 2
  • 15
  • 28

0 Answers0