Results 1 to 2 of 2

Thread: Parsing Phone Number out of String

  1. #1
    Join Date
    Jun 2007
    Posts
    1

    Exclamation Parsing Phone Number out of String

    Greetings,

    I have a varchar column called "Name" that was poorly implemented and contains the user name AND their phone number in the same column and I want to parse out the phone number and return just the Name.

    Ex. "Jeff Standard (123) 456-7890"

    Desired Result: "Jeff Standard"

    Another dilemma is the phone numbers are entered in an inconsistent manner, they could be of any of these formats:
    (xxx) xxx-xxxx
    xxx-xxx-xxxx
    xxx xxx-xxxx

    I was looking at creating this as a stored procedure and calling it from Excel to load it into a reporting template.

    I've fiddled around with REGEXPs but unfortunately they are for pattern MATCHING and I can't find a decent way to apply them to parse out the phone number portion of the string, only filter it.

    I'm fairly new to MySQL, please bear with me.

    Thanks,

    - Jeff

  2. #2
    Join Date
    Jun 2007
    Posts
    3
    I don't use / like excel but if you had the option to go w/ a scripting language such as PHP. You could easily parse the result string with split using either a "(" or a number as the delimiter field.. then you'd have an array w/ 2 items.. name and phone number.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •