Re: Weird search and replace
| From: | Jason Wong | Date: | Thu, 06 Jan 2005 08:56:32 +0000 |
| Subject: | Re: Weird search and replace | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-205716@lists.php.net to get a copy of this message | ||
On Thursday 06 January 2005 14:24, Liam Gibbs wrote:
Please fix your mail client so that in word wraps properly!
> Here's what I need. I have a string such as this:
>
> "Yadda yadda yadda yadda '32'(l) yadda yadda yadda '2'(l) yadda
> '419'(l)."
> (#2)
>
> I need to find the strings like '32'(l), '2'(l), and '419'(l),
> including
> the single quotes. Basically a '[0-9]*'(l). This is #1.
>
> Take that string, look up a record in an SQL table based on the number in
> the single quotes. Take a field in the record (#3) and replace #1 with it.
> So basically, we have:
>
> "Yadda yadda yadda yadda supplanted-string yadda yadda yadda
> supplanted-string yadda supplanted-string." (#2)
It seems preg_replace_callback() would be ideal for this job.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
New Year Resolution: Ignore top posted posts