SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist GeekSupport's Avatar
    Join Date
    May 2002
    Location
    Southern California
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    (Resolved) RegExp Help: Extract only names (PIN Name)

    I have the following strings
    Code:
    	4036B885	Joe Cool/SACRAMENTO/WEST/Company
    	23E05622	Larry H Parker/ALISOVIEJO/WEST/Company
    		Maxwell Smart/PALMBEACH/EAST/Company
    I want to only take the full name. Some rows do or do not have a PIN

    Trying different combinations of

    Code:
    /[^\d]?.*(\w.*)/
    /[^\d].*(\w.*)/
    /[^\d]?.*(.*)/
    /\t(.*)/
    /\d\t(.*)/
    Don't seem to work. The closest I got was to getting all the rows with both a PIN and Name. Unfortunately I will lose the rows without a PIN. Any help would be greatly appreciated!

    BTW, I'm using this in PHP in preg_match_all()
    Last edited by GeekSupport; Nov 9, 2006 at 10:29.

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My Regex sucks, but I'll give it a try.

    Code:
    /[\dA-Z]*\b([^\d]+)/

  3. #3
    SitePoint Evangelist GeekSupport's Avatar
    Join Date
    May 2002
    Location
    Southern California
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jldbeck1
    My Regex sucks, but I'll give it a try.

    Code:
    /[\dA-Z]*([^\d]+)/
    Thanks! I'll give it a try when I get in tomorrow

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem. I just realized you said only full name in your post. So this new one should take everything up to the first '/'. And I'm assuming that you're searching line by line, if not, that most likely won't work.

    Code:
    /[\dA-Z]*\b([^\d\/]+)/

  5. #5
    SitePoint Evangelist GeekSupport's Avatar
    Join Date
    May 2002
    Location
    Southern California
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    jldbeck1:

    Almost there. Users without a PIN will be in the same index as the previous user


    String snippet
    Code:
    	400D0303	Gary McIntyre/SANFRANCISCO/WEST/Company
    		Gary Morgan/BROWARD/EAST/Company
    		Gary Sauerbrei/CHARLOTTE/EAST/Company
    preg_match_all snippet
    Code:
                [184] => 	Gary McIntyre/SANFRANCISCO/WEST/Company
    		Gary Morgan/BROWARD/EAST/Company
    		Gary Sauerbrei/CHARLOTTE/EAST/Company

  6. #6
    SitePoint Evangelist GeekSupport's Avatar
    Join Date
    May 2002
    Location
    Southern California
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jldbeck1
    No problem. I just realized you said only full name in your post. So this new one should take everything up to the first '/'. And I'm assuming that you're searching line by line, if not, that most likely won't work.

    Code:
    /[\dA-Z]*\b([^\d\/]+)/
    Sorry, I meant to say the full common name

    Code:
    First M Last/Certifier/Region/Company

  7. #7
    SitePoint Evangelist GeekSupport's Avatar
    Join Date
    May 2002
    Location
    Southern California
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it!

    Code:
    /[\dA-Z]*\b([^\d\t]+Company)/
    (without "Company" it will also extract junk text above the list)

    Thanks for all your help!!


Bookmarks

Posting Permissions

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