Jump to content

[SOLVED] Using preg_replace


play_

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.