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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.