Thursday, 15 May 2014

php - Regex for [title](http://) links -



php - Regex for [title](http://) links -

i'm trying parse links using php construction such [google](http://google.com), , far i've got this:

"/\[(.+?)\]((.+?\))/is"

the part can't work part parenthesis ')'.

any help great!

[edit]

@jari - part of code:

$find = array( "@\n@", "/[**](.+?)[**]/is", "/\[(.+?)\]\((.+?)\)/is" ); $replace = array( "<br />", "<strong>$1</strong>", "<a href\"$1\" target=\"_blank\" rel=\"no follow\"></a>" ); $body = htmlspecialchars($body); $body = preg_replace($find, $replace, $body); homecoming $body;

the parenthesis special character , marks sub-patterns within expression, need escape them (just did square brackets, btw):

"/\[(.+?)\]\((.+?)\)/is"

php regex hyperlink

No comments:

Post a Comment