PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Nov 21, 2019 8:19 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sat May 07, 2005 6:03 am 
Offline
Forum Contributor
User avatar

Joined: Tue Aug 10, 2004 3:08 am
Posts: 424


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 07, 2005 6:58 am 
Offline
DevNet Master

Joined: Tue Jan 20, 2004 12:11 am
Posts: 4897
Location: Leuven, Belgium
i would use preg_replace everything that is not [a-zA-Z0-9].

now it's up to you to lookup that function, and your regular expressions book how to write that ;)


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 07, 2005 8:32 am 
Offline
Site Admin
User avatar

Joined: Tue Dec 23, 2003 3:10 am
Posts: 11470
Location: Toronto
Moved to Regex.

Alternatively, if you do not wish to use regex, you could just a bunch of


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 07, 2005 11:33 am 
Offline
DevNet Master

Joined: Thu Jan 30, 2003 9:26 pm
Posts: 2893
Location: Glasgow, Scotland


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 07, 2005 6:04 pm 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
Syntax: [ Download ] [ Hide ]
$string = 'some text here 123 ***###@@;;;,,,&&^%%% stuff Exclaim!!!';

$newstring = preg_replace('/[^a-z\d\s]+/s', '', $string);

//some text here 123  stuff Exclaim


Should do it. Remove the \s to also strip out white-space from the string.

Problem with \W+ as McGruff says is that it leaves underscores ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group