I'm not too sure how I should word that title, apologies. x_x
I'm basically trying to convert a string to a formatted URL similar to how Reddit/Stackoverflow does it.
Eg. [Hello World](http://google.com)
= Hello World
Both of the following work, but they don't work when combined together.
preg_replace("/\[([^\]]+)\]/", ... //Works for [Hello World]
preg_replace("/\(([^\)]+)\)/", ... //Works for (Hello World)
preg_replace("/\[([^\]]+)\]/\(([^\)]+)\)/", ... //Doesn't work
Regex confuses me x_x Help appreciated!
Use this \[([^\[\]]*)\](.*)
$input_lines="[Hello World](http://google.com)";
preg_replace("/\[([^\[\]]*)\](.*)/", "$1", $input_lines);
$str = '[Hello World](http://google.com)';
preg_replace('/\[([^\]]+)\]\(([^\)]+)\)/', '<a href="$2">$1</a>', $str);