I have following syntax in my script to get email address from string. The email address contains – . 1234567890 _ characters. The email address is retrieved but not _ character before @ sign.
preg_replace("/<([a-z][a-z0-9]*)[^>]*?(\/?)>/i",'<$1$2>', $value);
For example: The email address in string is ahmad_khalid@yahoo.com , with above syntax it returns khalid@yahoo.com
You’d need to add in the _ character to your regex, so it would become
Alternately, you can do
Using the “word character” \w as shorthand