Regular Expression for Special Character

Discussion in 'PHP' started by Arunv, Oct 9, 2009.

  1. #1
    Hello, I want regular Expression for special character for validation. I have search in the google but I have not got sufficiant answer......!! So, can any one tell me..
     
    Arunv, Oct 9, 2009 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What special character exactly?
     
    JAY6390, Oct 10, 2009 IP
  3. unigogo

    unigogo Peon

    Messages:
    286
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Test it with PHP regular expression tester
     
    unigogo, Oct 11, 2009 IP
  4. phprightnow

    phprightnow Peon

    Messages:
    296
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If you're trying to remove/strip special characters, try this (removed everything but letters, numbers, and spaces)...

    function strip_special($str) {
     return preg_replace('/[^a-zA-Z0-9[:space:]]/', '', $str); 
    }
    PHP:
     
    phprightnow, Oct 11, 2009 IP