1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Regex to remove everything from a string before the first number

Discussion in 'Programming' started by Kellerkind, Apr 2, 2010.

  1. #1
    I have a little bit of a problem to figure this one out.

    $string = "This is the Episode 7: Great Title";

    How can I preg_replace this string to just get "7: Great Title"?
    The only pattern I have is that it will be the first number in the string. The string before the number varies. Any help would be great!
     
    Kellerkind, Apr 2, 2010 IP
  2. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #2
    $string = "This is the Episode 7: Great Title";
    echo preg_replace('#^([^\d]+)?#','',$string)."\n";
    
    PHP:
    Regards :)
     
    koko5, Apr 2, 2010 IP
  3. Kellerkind

    Kellerkind Active Member

    Messages:
    160
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    You are the man. Thank you very very much!
     
    Kellerkind, Apr 2, 2010 IP