Re: preg_replace
| From: | leam hall | Date: | Fri, 01 Nov 2013 15:45:56 +0000 |
| Subject: | Re: preg_replace | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-322403@lists.php.net to get a copy of this message | ||
Hey Jim,
The problem was tags. Most items had a tag "TAG00001", "TAG00002", etc.
Some had "TAG00000-SPECIAL001", "TAG000000-SPECIAL002". I was looking to
remove the "TAG00000-" bits. Using str_replace should take care of it.
Thanks!
Leam
On Fri, Nov 1, 2013 at 11:33 AM, Jim Lucas <lists@cmsws.com> wrote:
> On 11/01/2013 08:06 AM, leam hall wrote:
>
>> Despite my best efforts to ignore preg_replace, it seems the best answer
>> for the current problem. That is, if I can get it to work...
>>
>> Problem code:
>>
>> $remove = "TAG000000-";
>> $replaceWith = "";
>> $newTitle = preg_replace($remove, $replaceWith, $title);
>>
>> This, as well as using the $remove and $replaceWith as themselves and not
>> variables, gives:
>>
>> PHP Warning: preg_replace(): Delimiter must not be alphanumeric or
>> backslash
>>
>> Thoughts?
>>
>> Leam
>>
>>
> Can you offer a working example of the actual data you are working with
> and what you expect to happen? Besides preg_replace, what have you tried
> and what didn't work as expected?
>
> --
> Jim Lucas
>
> http://www.cmsws.com/
> http://www.cmsws.com/examples/
>
--
Mind on a Mission <http://leamhall.blogspot.com/>