...

View Full Version : Remove all symbols & quotes from string



mbhramar
03-10-2008, 08:59 AM
Hi,
I need to get the user input as a keyword for displaying ads.
In order to get strings which user inputs with quotes or symbols like %$#@, I need to strip the string off of any symbols but NOT spaces.

eg. If the user inputs:
Hello "World"!
It should return:
Hello World

I can only use the string with no symbols & quotes to include as keywords for the site.

Thanks

digitalfiz
03-10-2008, 09:16 AM
Best way is to use preg_replace to clean out everything but what you actually want to allow like so:


$input = preg_replace( "#[^a-zA-Z0-9 ]#", "", $input);This allows for only letters, numbers and spaces. Hope this helps :)

abduraooft
03-10-2008, 09:24 AM
mbhramar, Read the rules first http://www.codingforums.com/postguide.htm. Don't cross post!

mbhramar
03-10-2008, 04:09 PM
oh I am sorry. Actually Earlier on, I needed this functionality in PHP. But then I realized that I actually need it in Javascript. So I ended up posting it again in Javascript.

mbhramar
03-10-2008, 04:09 PM
digitalfiz, Thanks alot bro for the solution.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum