Jump to content

regular expression


billli

Recommended Posts

Hi!

 

I'm trying to convert two wiki like tags to their html counter part.

 

ie) [[WikiPage]] => <a href="index.php?p=wiki/view&page=WikiPage" rel="nofollow" title="WikiPage">WikiPage</a>

and

[[WikiPage|Title]] => <a href="index.php?p=wiki/view&page=WikiPage" rel="nofollow" title="Title">Title</a>

 

	
	$string = htmlentities($string);
	$simple_search = array(
		'/\[\[(.*?!\|)\|(.*?)\]\]/is',
		'/\[\[(.*?)\]\]/is');

	$simple_replace = array(	
		'<a href="index.php?p=wiki/view&page=$1" rel="nofollow" title="$2">$2</a>',
		'<a href="index.php?p=wiki/view&page=$1" rel="nofollow" title="$1">$1</a>'
	);


 

Could anyone help me with the two regular expressions?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/193023-regular-expression/
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.