Jump to content

Preg Replace (Bad Syntax) REGEXP


d22552000

Recommended Posts

Well, I am making a web proxy, and I need to replace the url's the website (all of them) to point to sim_post.php?u=serializedurlhere .  (Including images and scripts.) so I took a look around the web and tried to create a preg_replacement, it failed.

 

Here is the error:

Parse error: syntax error, unexpected '.', expecting ')' in C:\WOS\www\sim_post.php(22) : regexp code on line 1

Fatal error: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Failed evaluating code: '/sim_post.php?u=/'.'\['.serialize(.'2'.).']' in C:\WOS\www\sim_post.php on line 22

 

and this is the php code:

	$pattern = "/(<a href=\")(.+?)(\")(\s*)(>)(.+?)(<\/a>)/e";
	$replace = "'/sim_post.php?u=/'.'\\['.serialize(.'2'.).']'";

	$page = do_post($_POST['url']);

	preg_replace($pattern, $replace, $page);

 

I really do not know how to use regexp, and took a source to make links indexes from a google search.  To be honest, it may be easier to create a whole new pattern and replacement, in comparison to trying to fix mine.  I suck at regex ><.

Link to comment
https://forums.phpfreaks.com/topic/119437-preg-replace-bad-syntax-regexp/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.