Need Regular Expression Help

Discussion in 'PHP' started by LeetPCUser, Jul 13, 2009.

  1. #1
    I need to build a regular expression and am not good at it. I have the following string:

    blah blah blah {...

    where blah blah blah is dynamic.

    I want to truncate all of the data before this first {. There will be {'s after this one and I only want to match the first case and truncate all before it in PHP.

    Can someone please help me?
     
    LeetPCUser, Jul 13, 2009 IP
  2. austin-G

    austin-G Peon

    Messages:
    435
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    preg_replace( '/[a-zA-Z0-9 ]*}(.*)/', '$1', $string );

    Something like that might work. Could 'blah blah blah' contain all characters of just alphanumeric?
     
    austin-G, Jul 13, 2009 IP
  3. megaresp

    megaresp Peon

    Messages:
    80
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    megaresp, Jul 13, 2009 IP
  4. LeetPCUser

    LeetPCUser Peon

    Messages:
    711
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    austin-G, this will contain any number of characters and letters. Also, what is the $1?
     
    LeetPCUser, Jul 14, 2009 IP