How would I create a preg_replace that would replace all the special characters yet..

Discussion in 'PHP' started by Imozeb, Apr 24, 2010.

  1. #1
    I need a preg_replace that will delete all special characters except full-stops, commas, exclamation points, and question-marks. How would I do this?

    Thanks.
     
    Imozeb, Apr 24, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    preg_replace('~[^\.,!\?]+~', '', $str);
    PHP:
     
    danx10, Apr 24, 2010 IP