Re: [PHP] Stripping Characters

2010-06-23 Thread Richard Quadling
On 23 June 2010 01:03, Rick Dwyer rpdw...@earthlink.net wrote: $find = '/[^a-z0-9]/i'; Replace that with ... $find = '/[^a-z0-9]++/i'; And now you only need ... $new_string = trim(preg_replace($find, $replace, $old_string)); -- - Richard Quadling Standing on the shoulders of some very

[PHP] Stripping Characters

2010-06-22 Thread Rick Dwyer
Hello List. I need to remove characters from a string and replace them with and underscore. So instead of having something like: $moditem = str_replace(--,_,$mystring); $moditem = str_replace(?,_,$mystring); $moditem = str_replace(!,_,$mystring); etc. For every possible character I can

RE: [PHP] Stripping Characters

2010-06-22 Thread David Česal
-general@lists.php.net Subject: [PHP] Stripping Characters Hello List. I need to remove characters from a string and replace them with and underscore. So instead of having something like: $moditem = str_replace(--,_,$mystring); $moditem = str_replace(?,_,$mystring); $moditem = str_replace

Re: [PHP] Stripping Characters

2010-06-22 Thread Ashley Sheridan
On Tue, 2010-06-22 at 11:40 -0400, Rick Dwyer wrote: Hello List. I need to remove characters from a string and replace them with and underscore. So instead of having something like: $moditem = str_replace(--,_,$mystring); $moditem = str_replace(?,_,$mystring); $moditem =

Re: [PHP] Stripping Characters

2010-06-22 Thread Shreyas Agasthya
Perhaps, ereg_replace(your regex, replacement_string, String $variable). Regards, Shreyas On Tue, Jun 22, 2010 at 9:10 PM, Rick Dwyer rpdw...@earthlink.net wrote: Hello List. I need to remove characters from a string and replace them with and underscore. So instead of having something

Re: [PHP] Stripping Characters

2010-06-22 Thread Richard Quadling
On 22 June 2010 16:44, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-06-22 at 11:40 -0400, Rick Dwyer wrote: Hello List. I need to remove characters from a string and replace them with and underscore. So instead of having something like: $moditem =

Re: [PHP] Stripping Characters

2010-06-22 Thread Nathan Nobbe
On Tue, Jun 22, 2010 at 9:40 AM, Rick Dwyer rpdw...@earthlink.net wrote: Hello List. I need to remove characters from a string and replace them with and underscore. So instead of having something like: $moditem = str_replace(--,_,$mystring); $moditem = str_replace(?,_,$mystring);

Re: [PHP] Stripping Characters

2010-06-22 Thread Shreyas Agasthya
Then, when does one use ereg_replace as against preg_replace? I read from one the forums that preg_* is faster and ereg_* is if not faster but simpler. Is that it? Regards, Shreyas On Tue, Jun 22, 2010 at 9:58 PM, Richard Quadling rquadl...@gmail.comwrote: A word character is any letter or

Re: [PHP] Stripping Characters

2010-06-22 Thread Rick Dwyer
Thanks to everyone who responded. Regarding the myriad of choices, isn't Ashley's, listed below, the one most like to guarantee the cleanest output of just letters and numbers? --Rick On Jun 22, 2010, at 11:44 AM, Ashley Sheridan wrote: On Tue, 2010-06-22 at 11:40 -0400, Rick Dwyer

Re: [PHP] Stripping Characters

2010-06-22 Thread Ashley Sheridan
On Tue, 2010-06-22 at 13:35 -0400, Rick Dwyer wrote: Thanks to everyone who responded. Regarding the myriad of choices, isn't Ashley's, listed below, the one most like to guarantee the cleanest output of just letters and numbers? --Rick On Jun 22, 2010, at 11:44 AM, Ashley

Re: [PHP] Stripping Characters

2010-06-22 Thread Jim Lucas
Shreyas Agasthya wrote: Then, when does one use ereg_replace as against preg_replace? I read from one the forums that preg_* is faster and ereg_* is if not faster but simpler. BUT, all the ereg_* has been depricated. DO NOT USE THEM if you want your code to work in the future. :) Is that

Re: [PHP] Stripping Characters

2010-06-22 Thread Rick Dwyer
Hello again list. My code for stripping characters is below. I'm hoping to get feedback as to how rock solid it will provide the desired output under any circumstance: My output must look like this (no quotes): This-is-my-string-with-lots-of-junk-characters-in-it The code with string

Re: [PHP] Stripping Characters

2010-06-22 Thread Ashley Sheridan
On Tue, 2010-06-22 at 20:03 -0400, Rick Dwyer wrote: Hello again list. My code for stripping characters is below. I'm hoping to get feedback as to how rock solid it will provide the desired output under any circumstance: My output must look like this (no quotes):

Re: [PHP] Stripping Characters

2010-06-22 Thread Rick Dwyer
Very good. Thank you. --Rick On Jun 22, 2010, at 8:14 PM, Ashley Sheridan wrote: On Tue, 2010-06-22 at 20:03 -0400, Rick Dwyer wrote: Hello again list. My code for stripping characters is below. I'm hoping to get feedback as to how rock solid it will provide the desired output under

[PHP] Stripping characters.....

2002-04-28 Thread CDitty
Hello all, Does anyone have any snippets of code that will strip several characters from a string? I am trying to figure out how to do this without using 3 different if statement blocks. This is what I am looking for. ieUser email address is Chris Ditty [EMAIL PROTECTED] or Chris

Re: [PHP] Stripping characters.....

2002-04-28 Thread Justin French
Clarification: So really, what you want to achieve is to ONLY have the email address? I'm POSITIVE there's a better way with ereg_replace(), but I haven't got time to experiment, and i'm no expert :) So, what I figured was that you would loop through the $email, and if the first char wasn't a ,