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? Link to comment https://forums.phpfreaks.com/topic/33438-solved-using-preg_replace/ 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] Link to comment https://forums.phpfreaks.com/topic/33438-solved-using-preg_replace/#findComment-156710 Share on other sites More sharing options...
play_ Posted January 9, 2007 Author Share Posted January 9, 2007 thank you Link to comment https://forums.phpfreaks.com/topic/33438-solved-using-preg_replace/#findComment-156739 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.