Weird search and replace
| From: | Liam Gibbs | Date: | Thu, 06 Jan 2005 06:24:03 +0000 |
| Subject: | Weird search and replace | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-205713@lists.php.net to get a copy of this message | ||
I'm trying to do a search-and-replace for a certain string (#1) from a bigger string (#2), take
that string (#1), do an SQL search, then do a little fiddling to make another string (#3), and put
that string (#3) back into the big string (#2) to replace the certain string (#1).
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)
I really hope I'm explaining this properly, and after a few attempts, I have no clue where to
restart. Does anyone have any ideas how to do this?