Chris Lane
asked on
Separate email addresses with regular expression.
Hi,
I have written a regular expression to capture an email address from a specific zone on a page using a software application.
The application will then send a copy of the document to that email address.
I have come across two problems. First is that email addresses can contain numeric values as well as text. Problem solved by adding 0-9 in the regex.
Second issue is that some of the documents have more than one email address separated by / (forward slash).
Is there an easy way to find the / and stop returning any further email addresses?
The first address will always be the one I need.
Thanks in advance,
Chris.
I have written a regular expression to capture an email address from a specific zone on a page using a software application.
The application will then send a copy of the document to that email address.
I have come across two problems. First is that email addresses can contain numeric values as well as text. Problem solved by adding 0-9 in the regex.
Second issue is that some of the documents have more than one email address separated by / (forward slash).
Is there an easy way to find the / and stop returning any further email addresses?
The first address will always be the one I need.
Thanks in advance,
Chris.
ASKER
That looks like it will do the trick. Thanks for the advice. Is there a simpler way to do it using the same regular expression?
I'm using regex buddy and it doesn't like the "/" at all!
I'm using regex buddy and it doesn't like the "/" at all!
use "\/"
ASKER
I will try that now.
Thanks for your help.
Chris.
Thanks for your help.
Chris.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, Leonidas.
I will try that tomorrow on my VM and let you know if it works in my application.
Regards,
Chris.
I will try that tomorrow on my VM and let you know if it works in my application.
Regards,
Chris.
Open in new window
demo
https://jsfiddle.net/538oyfco/