I want to write a class that color codes PHP syntax like on this forum (I know they already exist but I want to code my own for the experience). Are there any suggestions on what approach to take while doing this. One approach I have thought of is to use a bunch of preg_replaces but I know regex can slow things down if I do a lot of it. Another approach is to split the code into an array of PHP and non PHP (outside PHP tags), and then run regex on the PHP code while leaving the non PHP code alone, and then putting the array back together as one. I have a feeling this will take me a while to do and don't want to take one approach, then realize a different approach would have been better. Thanks,
Matt