play_ Posted January 9, 2007 Share Posted January 9, 2007 I'd like to inform i went on to make my own syntax hiliter, thought it was the best way to start off with regular expressions.Problem i'm having...$text = 'some part of some thing... """ comment in pyton """';What i'd like to do is, take everything from """ to the next """ and change the color.I have this:echo preg_replace("[\"\"\"]", "<span style=\"color: blue\">\${0}</span>", $text); But that just changes the """ to blue. not the text between them.Also, is regexp even the best/right approach to syntax hiliting? Say i have a comment inside a comment. Would there be a way to let regexp know that it's mean to be ignored? Quote Link to comment Share on other sites More sharing options...
Nicklas Posted January 9, 2007 Share Posted January 9, 2007 [code=php:0]echo preg_replace('/(""").*?\1/s', '<span style="color: blue">\\0</span>', $text);[/code] Quote Link to comment Share on other sites More sharing options...
play_ Posted January 9, 2007 Author Share Posted January 9, 2007 thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.