[PHP] str_replace or regex
Hi, I was wondering if I can get some help with either a str_replace or a regex. I have some data and it always begins with $$ but it can end with any letter of the alphabet. so sometimes its $$a and sometimes its $$b and sometimes $$c all the way to $$z. $$a all the way to $$z needs to be changed to a / So is there a way to do this? I was thinking of a str_replace but since the letter always changes I'm not so sure. Any help? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace or regex
Hello Adam, Thursday, March 18, 2004, 6:06:06 PM, you wrote: AW Hi, I was wondering if I can get some help with either a str_replace or a AW regex. I have some data and it always begins with $$ but it can end with AW any letter of the alphabet. so sometimes its $$a and sometimes its $$b AW and sometimes $$c all the way to $$z. $$a all the way to $$z needs to AW be changed to a / So is there a way to do this? I was thinking of a AW str_replace but since the letter always changes I'm not so sure. Any help? If I read that correctly, you want to replace $$ with /, yes? In which case a str_replace will do that just fine. Ignore the final letter of the string and just search for $$ and replace with a /. -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace or regex
From: Adam Williams [EMAIL PROTECTED] Hi, I was wondering if I can get some help with either a str_replace or a regex. I have some data and it always begins with $$ but it can end with any letter of the alphabet. so sometimes its $$a and sometimes its $$b and sometimes $$c all the way to $$z. $$a all the way to $$z needs to be changed to a / So is there a way to do this? I was thinking of a str_replace but since the letter always changes I'm not so sure. Any help? $output = preg_replace('/\$\$[a-z]/','/',$string); If you wanted to use str_replace, then: $array = array('$$a','$$b','$$c','$$d'...); $output = str_replace($array,'/',$string); ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace or regex
eregi_replace('(\$\$)([a-z].+)', '\1z', '$$a'); Maybe i'm wrong, please crosscheck. Regards, Firman - Original Message - From: Adam Williams [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, March 19, 2004 1:06 AM Subject: [PHP] str_replace or regex Hi, I was wondering if I can get some help with either a str_replace or a regex. I have some data and it always begins with $$ but it can end with any letter of the alphabet. so sometimes its $$a and sometimes its $$b and sometimes $$c all the way to $$z. $$a all the way to $$z needs to be changed to a / So is there a way to do this? I was thinking of a str_replace but since the letter always changes I'm not so sure. Any help? -- 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