i am coding a forum, when the user send the post i analyse his message to extract text between <code> and </code>
If the user use only once the tag, everything goes well, but if the user for exemple use the tag in a comment to debug his code for exemple, how can i select the right tag ?
possible post exemple:
<code>
aaaaaaaaaaa
// comment <code> comment
bbbbbbbbbbb
/ comment </code> /
ccccccccccc
/
</code>
**/
ddddddddddd
</code>
it is possible to write a intelligent regex who will analyse if the tag is commented ?
the current solution i've found is to first search for text matching between / & / and temporary rename the founded <code> tag, same for //. After this step the remaining tag should be the good one, i simply have to search for text matching between<code> & </code> then after formatting the text, str_replace the renamed tag to ther initial state
i know it's not really optimised, so there is a better way to extract the correct part of code ?