RE: [PHP] str_replace question

2003-09-10 Thread SLanger
> preg_replace('/*\<[a-z]+)[0-9]+(\>)/', '$1$2', $String);
Ok why not simply use reg_replace('//', '//', $String);

BTW preg regex are more powerfull since they support some stuff that the 
posix standard does not support. As far as I know lookbehinds and 
lookbacks and stuff like that. Also the POSIX standard dictates that all 
matches must be provided and the longest match is choosen. Preg on the 
other hand simply returns the first found match and is therefor faster.

Please  correct me if I'm wrong!!

Regards
Stefan Langer

RE: [PHP] str_replace question

2003-09-09 Thread Robert Cummings
I think (and don't quote me on this, and feel free to correct me :) that
preg_replace() is fast being based on perl regular expressions.
ereg_replace() however, follows the POSIX standard for regular
expression matching.

Cheers,
Rob.

On Tue, 2003-09-09 at 17:36, Wouter van Vliet wrote:
> $String = "";
> preg_replace('/*\<[a-z]+)[0-9]+(\>)/', '$1$2', $String);
> 
> will most likeley do.
> 
> Btw, does anybody know why preg_replace is adviced over ereg_replace in the
> manual? .. and if ereg_replace doesn't have any advantages over
> preg_replace, couldn't this function get depricated?
> 
>  -> -Oorspronkelijk bericht-
>  -> Van: Al [mailto:[EMAIL PROTECTED]
>  -> Verzonden: dinsdag 9 september 2003 23:21
>  -> Aan: [EMAIL PROTECTED]
>  -> Onderwerp: [PHP] str_replace question
>  ->
>  ->
>  -> I've got a simple expression " where "xx" is a number
>  -> from 0 to 99.
>  ->
>  -> I want to replace it with simply .  That is, I want to remove the
>  -> numbers.
>  ->
>  -> Will "str_replace" do it, or must I use ereg_replace?
>  ->
>  -> I haven't figured out from reading the php manual on regular expression
>  -> how to do this simple thing.
>  ->
>  -> Thanks
>  ->
>  -> --
>  -> PHP General Mailing List (http://www.php.net/)
>  -> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
-- 
.-.
| Worlds of Carnage - http://www.wocmud.org   |
:-:
| Come visit a world of myth and legend where |
| fantastical creatures come to life and the  |
| stuff of nightmares grasp for your soul.|
`-'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] str_replace question

2003-09-09 Thread Wouter van Vliet
$String = "";
preg_replace('/*\<[a-z]+)[0-9]+(\>)/', '$1$2', $String);

will most likeley do.

Btw, does anybody know why preg_replace is adviced over ereg_replace in the
manual? .. and if ereg_replace doesn't have any advantages over
preg_replace, couldn't this function get depricated?

 -> -Oorspronkelijk bericht-
 -> Van: Al [mailto:[EMAIL PROTECTED]
 -> Verzonden: dinsdag 9 september 2003 23:21
 -> Aan: [EMAIL PROTECTED]
 -> Onderwerp: [PHP] str_replace question
 ->
 ->
 -> I've got a simple expression " where "xx" is a number
 -> from 0 to 99.
 ->
 -> I want to replace it with simply .  That is, I want to remove the
 -> numbers.
 ->
 -> Will "str_replace" do it, or must I use ereg_replace?
 ->
 -> I haven't figured out from reading the php manual on regular expression
 -> how to do this simple thing.
 ->
 -> Thanks
 ->
 -> --
 -> PHP General Mailing List (http://www.php.net/)
 -> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] str_replace question

2003-09-09 Thread Al
I've got a simple expression " where "xx" is a number from 0 to 99.

I want to replace it with simply .  That is, I want to remove the 
numbers.

Will "str_replace" do it, or must I use ereg_replace?

I haven't figured out from reading the php manual on regular expression 
how to do this simple thing. 

Thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] str_replace question

2002-09-01 Thread Gregor JakĀ¹a

Hello, i have array $reserved_words which i want to replace with bold ..
but when i tried to do str_replace($reserved_words,
"".$reserved_words."", $string) it showed Array instead of
word
if i simply do  str_replace($reserved_words, $reserved_words, $string) then
it shows the words not Array but not in bold ;)
I know i could use 2 arrays one with bold words one without or i could use
foreach but i want a simpler solution :)... Any suggestions ?


thx in advance !



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] str_replace question

2002-04-16 Thread Andrey Hristov

preg_replace('/\d+/','',$the_string);

Hope this helps.

Andrey

- Original Message - 
From: "Andras Kende" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 16, 2002 4:29 AM
Subject: [PHP] str_replace question


> Is a nicer way to remove any number 1-0 from a string???
> 
> Currently:
> $metakeywords=str_replace("1",'',strtolower($metakeywords));
> $metakeywords=str_replace("2",'',strtolower($metakeywords));
> $metakeywords=str_replace("3",'',strtolower($metakeywords));
> $metakeywords=str_replace("4",'',strtolower($metakeywords));
> $metakeywords=str_replace("5",'',strtolower($metakeywords));
> $metakeywords=str_replace("6",'',strtolower($metakeywords));
> ..
> 
> Thanks :)
> 
> Andras Kende
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] str_replace question

2002-04-15 Thread Justin Blake

"Andras Kende" <[EMAIL PROTECTED]> wrote:

> Is a nicer way to remove any number 1-0 from a string???
> 
> Currently:
> $metakeywords=str_replace("1",'',strtolower($metakeywords));
> $metakeywords=str_replace("2",'',strtolower($metakeywords));
> $metakeywords=str_replace("3",'',strtolower($metakeywords));
> $metakeywords=str_replace("4",'',strtolower($metakeywords));
> $metakeywords=str_replace("5",'',strtolower($metakeywords));
> $metakeywords=str_replace("6",'',strtolower($metakeywords));
> ..

use a regular expression with ereg_replace(), like this:

$metakeywords = ereg_replace('[0-9]', '', $metakeywords);

hope that helps
justin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] str_replace question

2002-04-15 Thread Andras Kende

Is a nicer way to remove any number 1-0 from a string???

Currently:
$metakeywords=str_replace("1",'',strtolower($metakeywords));
$metakeywords=str_replace("2",'',strtolower($metakeywords));
$metakeywords=str_replace("3",'',strtolower($metakeywords));
$metakeywords=str_replace("4",'',strtolower($metakeywords));
$metakeywords=str_replace("5",'',strtolower($metakeywords));
$metakeywords=str_replace("6",'',strtolower($metakeywords));
..

Thanks :)

Andras Kende



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php