I think I'm going about this the wrong way, but here's what I'm doing.
I have a string passed to me from my PBX, which I'm attempting to grab only the phone number, and even the text inside the double quotes, if they exist.
<?php
$string = '"John Smith" <sip:[email protected]:5060;user=phone>';
?>
I'm positive using a form of regex will be better to grab the number and name in separate variables, but since I'm not too good at regex yet, I'm resorting to explode()
I'm not doing too well with it, and it's getting messing with exploding the string at the @
sign, then at the :
. This leaves the name.
How would I strip out the number after the <sip:
before the @
?
/"([^"])+"\D+(\d+)/
. This regex can (and should) be improved (adding<sip:(\d+)@
part check instead of simple(\d+)
, for example) if the strings you're working with can be of different format.