How do I write an email template in mysql?

What I've tried looks like this:

mysql> select 'abc@b.c' REGEXP '[a-zA-Z0-9_]+(?:[\-\+\.][a-zA-Z0-9_]+)*@[a-zA-Z0-9_]+(?:[\-\.\+][a-zA-Z0-9_]+)*\.[a-zA-Z0-9_]+(?:[\-\.\+][a-zA-Z0-9_]+)*';

      

ERROR 1139 (42000): Error "operand of repetition-operator is invalid" from regexp

And I don't know what's wrong with him.

Can anyone here give me one that might work?

Thank you so much!

0


source to share


2 answers


A simple regex that should match most email addresses:



[A-z0-9_.%+-]+@[A-z0-9_.%+-]+\.[A-z]{2,4}

      

+1


source


See here to learn about validating email with regular expressions. It looks like a pretty daunting task :-)



0


source







All Articles