Search found 3 matches

by csh
Mon Sep 10, 2007 2:08 pm
Forum: Regex
Topic: manipulating preg_replace() variables
Replies: 2
Views: 1362

I think I got it. I think the following works: preg_replace("/\<a href='(.*)'(.*)\>/ e ", " ' <a href= \ 'http://www.new.com?url=[b]'[/b].urlencode( ' $1 ' ). '\ '$2> ' ", $content); (Note that I had forgotten to put the slashes around the regular expression in the first post, bu...
by csh
Mon Sep 10, 2007 12:51 pm
Forum: Regex
Topic: finding a right reg_exp for preg_replace() function
Replies: 2
Views: 1163

The reason it's changing the first one is because of the greedy/non-greedy problem. I think if you change your code to this:

$body=preg_replace('/<p>(.*?)<\/p><\/div>/U','<p>Author: $1</p></div>',$body);

The U argument should fix the problem.
by csh
Mon Sep 10, 2007 12:38 pm
Forum: Regex
Topic: manipulating preg_replace() variables
Replies: 2
Views: 1362

manipulating preg_replace() variables

Let's say I want to change the href attribute to be an argument of another url for all my <a> elements. For example: Change: http://www.old.com To: http://www.new.com?url=[b]http//www.old.com[/b] I need to urlencode the old url, but can't figure out how to do it. If I use: preg_replace("\<a hre...