www.webdeveloper.com
Results 1 to 9 of 9

Thread: anyway to remove ONLY symbols from text?

  1. #1
    Join Date
    Aug 2006
    Posts
    152

    anyway to remove ONLY symbols from text?

    Hi everyone,
    I was wondering if there's a way to to remove ONLY symbols from text?
    I know I can use preg_replace to keep only letters and numbers but the problem is that doesn't work on eastern languages like arabic, so any idea how to solve it?

    Thank you...


    btw I tried sth and It worked just doesn't look that professional


    PHP Code:
    $order   = array('!''@''#''$''%''^''&''*''_''-''=''+'':')

     
    $post_text str_replace($order''$post_text); 

  2. #2
    Join Date
    Nov 2008
    Posts
    2,477
    PHP Code:
    $str 'eà@aeê!ﺕæâlúù?ûa:eeـثتـ‎ظف';
    echo 
    preg_replace('/[^\p{L}0-9]/iu'''$str); // eàaeêﺕæâlúùûaeeـثتـظف 
    Last edited by Mindzai; 07-07-2010 at 03:21 AM. Reason: added some arabic characters to example
    The first rule of Tautology Club is the first rule of Tautology Club.

  3. #3
    Join Date
    Aug 2006
    Posts
    152
    can u modify it so it keeps spaces too?
    TY

  4. #4
    Join Date
    Aug 2006
    Posts
    152
    bump..

  5. #5
    Join Date
    Jan 2009
    Posts
    3,346
    Quote Originally Posted by SZero View Post
    can u modify it so it keeps spaces too?
    TY
    Did you try the existing one?

  6. #6
    Join Date
    Aug 2006
    Posts
    152
    ofcourse..

  7. #7
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    Code:
    '/[^\p{L}0-9 ]/iu'
                |
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  8. #8
    Join Date
    Aug 2006
    Posts
    152
    Quote Originally Posted by NogDog View Post
    Code:
    '/[^\p{L}0-9 ]/iu'
                |
    didn't work =S

  9. #9
    Join Date
    Nov 2008
    Posts
    2,477
    Can you post your code exactly as you have it written, because the above should work (unless your whitespace consists of characters other than spaces such as tabs).
    The first rule of Tautology Club is the first rule of Tautology Club.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles