gr68
gr68

Reputation: 502

Need a RegEx to match email To:

I need a regex to match this email header row

To: everything here <[email protected]> 

I could have also this case which should be matched too

To: everything here <[email protected]> <[email protected]>

In "everything here" there could be everything for example nothing, words, spaces, double quotes and so on.

I am trying this Regular expression

/^To:(?:)<myemail\@domain\.com\>/gm

but it does not work. I understood that (?:) should match everything .

Upvotes: 0

Views: 54

Answers (1)

MDR
MDR

Reputation: 2670

Possibly...

^To: (.*?) <.*$

Capture:

\1

Outputs:

everything here

https://regex101.com/r/GMi2rn/1

Upvotes: 2

Related Questions