Unfortunately, user input can make a simple 10-digit phone number sloppy (extra spaces, random dashes, etc.) but they always have one thing in common: they are always ten digits:

212-345-6789
-or-
212 3456789
-or-
2 12345 6789

I need a regex to find the person's name -- the first one or two words with a colon:

212-345-6789 SMITH: address here // "SMITH" would be desired result.
2 123456789 JOHN DOE: an address here // "JOHN DOE" would be desired result
2123456789 A. J. GRAHAM: address here // "A. J. GRAHAM" would be desired result

I think I would want my regex to "say" something like:
"everything after the 10th number," and
"up until the first colon."

I just don't know how to do "after the 10th number" when I don't know if the visitor entered dashes or spaces if any at all?

    If we assume the name will always start with a letter, followed by non-colon characters and then a colon, and the phone numbers will never have letters:

    if(preg_match('/^[^a-z]+([a-z][^:]*):/i', $string, $matches))
    {
        echo $matches[1];
    }
    else
    {
        echo "Not found. :(";
    }
    

    (untested)

      If there might be letters in among the phone numbers' digits...

      ^(?:[^0-9]*[0-9]){10}([^:]+):

      (also untested)

        Write a Reply...