0

I came up with the following

([\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})

I would also like to remove emails that start with a number or -. By remove I mean to select only the address and not to remove the entire match.

Is there a way to do that?

A.S.F Studio
  • 43
  • 1
  • 7
  • So that we know this isn't a duplicate, could you edit your question to clearly show which types of email addresses are valid and which are not? – Tim Biegeleisen Sep 26 '16 at 15:08
  • What language are you using? – Federico Piazza Sep 26 '16 at 15:09
  • 1
    Addresses starting with numbers are valid. I just created one with my convenient web application that allows users to easily create mail aliases: `[email protected]`. Please read the relevant RFC's, starting with 822, about what is valid e-mail syntax. About the only RFC feature you might think about rejecting is the use of comments. (Yes, e-mail addresses can contain comments, which is text enclosed in parentheses!) – Kaz Sep 26 '16 at 15:11

1 Answers1

0

^(?:\d+|-+)?([\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})$

This should do the trick. It'll capture emails but also filter out ones that start with a number or the - character and pulls the email from it.

ThePerplexedOne
  • 2,920
  • 15
  • 30