I am Tryting to show wiki text in HTML in my app(Using cakephp). I use this expression for <h4>,<h5>,<h6>
'/^==== (.*) ====$/'
=> '<h4>\1</h4>',
'/^===== (.*) =====$/'
=> '<h5>\1</h5>',
'/^====== (.*) ======$/'
=> '<h6>\1</h6>',
[http://www.wikipedia.org Wikipedia]
will be shown as <ahref="www.wikipedia.org">Wikipedia </a>
[5|Text]
will show like <a href="http://fillpage/5/page_slug">Text</a>
[[6#HeadingB|Text ]]
will shown as <ahref="http://fillpage/6/page_slug#HeadingB>Text</a>
[[6#HeadingB]]
will shown as
<a href="http://fillpage/5/page_slug">PageTitle</a>
[media:631|Description|Position]
will shown as
<img class="position" src="http://fullpath/lang_code/631.jpg">
Description
I wan't to know how to make such regex for links(exactly like Wikipedia shows.) how to make it done. And how to match space b/w two brackets for links.