We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11413
    • 203 Posts
    I’m building a plugin that adds beautifier support to MODx, and I need someone to help me with the regular expression stuff. I want to parse the code and retrieve <LangName> and <Code> :
    <!--CODE:<LangName>-->
    <Code>
    <!--CODEEND-->


    <LangName> can be anything (it’s a part of a filename)
    <Code> can be any source code from any language

    I tried :

    preg_replace_callback('/<!--CODE:(.*)-->(.*)<!--CODEEND-->/s','HighLight',$document);


    and the callback function is something like that :

    function HighLight($matches) {
      $lang = $matches[1];
      $code = $matches[2];
      return $highlighter->highlight($lang,$code);
    }


    i dont get any error from my thing, but i’m not getting result too :p Logically that means that I don’t get the good part of the code. What is wrong in my pattern??

    thanks a lot in advance!

    Blaise
      Blaise Bernier

      www.medialdesign.com - Solutions for small business, hosting, design and more!