hello im makeing a parser in php
as you can see below it transform
*this* _this_ to something like this this
$db['profile']['information'] = str_replace( "\n" , "<br/>" , $db['profile']['information']);
$db['profile']['information'] = preg_replace('/\*([^\*]+)\*/', '<strong>\1</strong>', $db['profile']['information']);
$db['profile']['information'] = preg_replace('/_([^[_]+)_/', '<em>\1</em>', $db['profile']['information']);
$db['profile']['information'] = preg_replace('/\[img\]((?:[^\[]+|\[(?!img\]))*)\[img\]/', '<img src="\1" />', $db['profile']['information']);
the problem is is on the img .
example i have a url [img]123_460217980773_23232_11_*23123*_n.jpg[img] well you know what it will parse. its epic. can anybody help me solve it ?
and thanks for your time looking in
Adam Ramadhan
Regular expressions, while indeed useful in many situations, are definitely not the right tool for manual parsing languages of structured text, and Markdown can be counted as one of those.
If you want to use the same syntax as StackOverflow does, use a Markdown parser like this one.