I've used google cloud vision OCR to extract business card email string text from here and used the below regular expression to try to extract but without much good results. Any better suggestions to increase the performance?
function extract_emails($str){
// This regular expression extracts all emails from a string:
$regexp = '/([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i';
preg_match_all($regexp, $str, $m);
return isset($m[0]) ? $m[0] : array();
}
$Email = extract_emails($gcv_response);
if (!empty($Email))
{
$Email = reset($Email);
}
else
{
$Email = 'NULL';
}
OCR text 1: "ALGEN MARINE PTE LTD Specialist in Fire Protection and Safety Engineering Philip Cheng Assistant Sales Manager 172 Tuas South Avenue 2, West Point Bizhub, Singapore 637191 Email: philip @algen.comsg Website: www.algen.comsg Tel: (65) 6898 2292 Fax: (65) 6898 2202 (65) 6898 2813 HP : (65) 9168 9799"
Result from the running the above code = NULL; Desired output: philip@algen.comsg
OCR text 2: "Allan Lim Yee Chian Chief Executive Officer Alpha Biofuels (S) Pte Ltd LHCCBNFLN FR2 a mobile 9790 3063 tel 6264 6696 fax 6260 2082 C#01-05, 2 Tuas South Ave 2 Singapore 637601 tang. Steve. Eric@alphabiofuels.sg www.alphabiofuels.sg"
Result from the running the above code = NULL; Desired output: tang.Steve.Eric@alphabiofuels.sg;