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
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
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
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
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
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
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
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
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
"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
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
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
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
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");
>
thlink.net]
Sent: Tuesday, June 22, 2010 5:41 PM
To: php-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("--","_",&
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 possibl
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 "<
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
18 matches
Mail list logo