Regular Expressions

Discussion in 'PHP' started by dwill, Jun 29, 2007.

  1. #1
    Coming back to PHP after a long break....

    I seem to remember a regular expression to remove all characters from a string which aren't A-Z a-z 0-9

    Can anyone help please?
     
    dwill, Jun 29, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    $string = preg_replace('/[^a-z0-9]/i', null, $string);
    
    PHP:
     
    nico_swd, Jun 29, 2007 IP
  3. dwill

    dwill Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Many thanks!
     
    dwill, Jun 29, 2007 IP