php - Regex to seperate concatenated phone number and email -


i have strings unfortunately phone number , email concatenated this:

$phone_email = "617.651.3123mya123@some-site.com";

i'd able split between last number , first letter.

desired output

$phone = "617.651.3123"; $email = "mya123@some-site.com"; 

i'm using php strategy straightforward in language.

edit

i've tried many things including trying grab email removing digits. $email = preg_replace('#^\d+#', '', $phone_email); results in removing 617 ignoring .

as others have pointed out, splitting between "the last number , first letter" may not strategy, since email addresses can start numbers. said, believe asked for:

$phone_email = "617.651.3123mya123@some-site.com";  $matches = []; preg_match("/([^a-za-z]*)(.*)/", $phone_email, $matches);  $phone = $matches[1]; $email = $matches[2];  echo "phone: $phone\n"; echo "email: $email\n";  // output: // phone: 617.651.3123 // email: mya123@some-site.com 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -