need regex help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xuron
    Confirmed User
    • Nov 2003
    • 346

    #1

    need regex help

    I have lines that look like this

    12345678:firstname

    ID:Name

    What is the regex code for deleting everything after the ":"

    This is what I have so far, but its not getting all the characters

    Code:
    :[a-z\s]*$
  • Dvae
    Confirmed User
    • Feb 2005
    • 5326

    #2
    Try
    .*?\w+)\s*$
    .
    .

    Arguing with a troll is a lot like wrestling in the mud with a pig, after a couple of hours you realize the pig likes it.

    Comment

    • calmlikeabomb
      Confirmed User
      • May 2004
      • 1323

      #3
      PHP Code:
      
      $item='12345678:firstname';
      
      $parts=explode(':', $item);
      
      //Outputs
      
      $parts[0]='12345678';
      $parts[1]='firstname'; 
      
      subarus.

      Comment

      Working...