SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    preg_replace question

    Hi

    How can I add special characters to the following preg_replace

    PHP Code:
                        $plaintext preg_replace("/[^a-z0-9 _\.:;,\-\@\r\n\/]+/i"""$response); // Remove special chars 

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    $plaintext = preg_replace("/[^a-z0-9 _\.:;,\-\@\r\n\/]+/i", "", $response);
    =>
    $plaintext = preg_replace("/[^a-z0-9 _\.:;,\-\@\r\n\/]+/i", "", $response);
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    $plaintext = preg_replace("/[^a-z0-9 _\.:;,\-\@\r\n\/]+/i", "", $response);
    =>
    $plaintext = preg_replace("/[^a-z0-9 _\.:;,\-\@\r\n\/]+/i", "", $response);
    Thanks I tried that, but it's still replacing the special letters

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Zaggs View Post
    Thanks I tried that, but it's still replacing the special letters
    Odd, works for me... you could try specifying the UTF-8 modifier on the string (/i => /iu)
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •