So I have a tag like [code style=php]<?php echo "Hello world!"; ?>[/code]
A user may use plenty of those tags in a textarea so what I want to search for is [code style=(.*)]text[/code] so if the style is PHP for example I want to do highlight the code inside the tags and so on with other languages.
Why reinvent the wheel. Stackoverflow already has answer for this: PHP syntax highlighting
UPDATE
After reading comment. You can convert it like this:
Here’s some test code: