iamadnan
iamadnan

Reputation: 113

Regex for matching a mix of delimited tokens and email address

I need to validate a string for valid email addresses or specific tokens (later to be replaced by email addresses) or a mix of both delimited by semi-colon. I need a little help with this regex I nearly got working. It matches the tokens but not the email address at the start or end.

^(((<#a#>)+|[;])*|(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*|((<#a#>)+|[;])*)$

Upvotes: 0

Views: 42

Answers (1)

iamadnan
iamadnan

Reputation: 113

Here is the answer posted by AlexBay which is working with my test data.

^((<#a#>)+|[;]|(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})‌​+)+$

Upvotes: 1

Related Questions