Regex to extract emails in WebHarvy

I am trying to handle Regex to extract email addresses from WP directory using WebHarvy (.NET)

Letters can be in several formats using dots and underscores, so I tried the following expressions

(\w+|\w+(\W|\.)\w+)@\w+.\w+
\w.+|\w+\S\w+@\w+\.\w+

      

While they seem to work in the Regexstorm test, when I use them in WebHarvy, they only retrieve the portion preceding @

Please inform

+3


source to share


1 answer


The problem is that WebHarvey is returning the capturing group value. Since you wrapped the user part with the capture ( (\w+|\w+(\W|\.)\w+)

) group , it only returns that part.

You can fix your regex using a non-capturing ( (?:...)

) group like

(\w+(?:\W+\w+)*@\w+\.\w+)

      



or use the more general

([^\s<>'"]+@[^\s<>'"]+\.[^\s<>'"]+)

      

[^\s<>'"]+

1+ will match the characters other than the space character, <

, >

, '

and "

. @

and \.

correspond to a @

and a, .

respectively.

+2


source







All Articles