views:

77

answers:

1

Hello,

Let's say I have this:

<div id="wrapper">
 <pre class="highlight">
    $(function(){
    // hide all links except for the first
    $('ul.child:not(:first)').hide();
    $("a.slide:first").css("background-color","#FF9900");

    /*
        The comment goes here.
    */

  </pre>
</div>

With Jquery, I want to find what is in between:

    /*
        The comment goes here.
    */

Including those comment signs. So it should return:

    /*
        The comment goes here.
    */

How to do that, how to find text between two points?

Thanks

+3  A: 

Well, the fastest and ugliest way to do this is like this :

var t = $('pre.highlight').html();
$('pre.highlight').html(
   t.replace(/(\/\*[.\S\s]*\*\/)/,'<span class="comment">$1</span>')
);

Maybe could replace open search and closure search with vars

var s = "\/\*";
var c = "\*\/";
var rexp = RegExp( s + "[.\S\s]*" + c )

Dunno, just brainstorming

markcial
+1: That's good, let me see if there are more options. Thanks
Sarfraz