Re: [PHP] Stripping Characters

2010-06-23 Thread Richard Quadling
On 23 June 2010 01:03, Rick Dwyer 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 clever giants!" EE

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 a

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): > > "This-is

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 l

Re: [PHP] Stripping Characters

2010-06-22 Thread Rick Dwyer
On Jun 22, 2010, at 1:41 PM, Ashley Sheridan wrote: It is clean, but as Richard mentioned, it won't handle strings outside of the traditional 128 ASCII range, so accented characters and the like will be converted to an underscore. Also, spaces might become an issue. However, if you are

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

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, As

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 wrot

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 wrote: > "A "word" character is any letter or digit or the und

Re: [PHP] Stripping Characters

2010-06-22 Thread Richard Quadling
"A "word" character is any letter or digit or the underscore character, that is, any character which can be part of a Perl "word". The definition of letters and digits is controlled by PCRE's character tables, and may vary if locale-specific matching is taking place. For example, in the "fr" (Frenc

Re: [PHP] Stripping Characters

2010-06-22 Thread Nathan Nobbe
On Tue, Jun 22, 2010 at 9:40 AM, 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"); > $modit

Re: [PHP] Stripping Characters

2010-06-22 Thread Richard Quadling
On 22 June 2010 16:44, Ashley Sheridan 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 = str_replace("--","_","$mystring

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 wrote: > Hello List. > > I need to remove characters from a string and replace them with and > underscore. > > So instead of having something like: > > $modi

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"); >

RE: [PHP] Stripping Characters

2010-06-22 Thread David Česal
Hello, can this resolve your problem? $trans = array( "from" => "to", "another" => "to"); $moditem = StrTr($moditem, $trans); -- http://cz.php.net/manual/en/function.strtr.php David -Original Message- From: Rick Dwyer [mailto:rpdw...@earthlink.net] Sent: Tuesday, June 22, 2010 5:41 PM

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

2002-04-27 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 "<