Reputation: 382806
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?
Upvotes: 1
Views: 393
Reputation: 9333
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
Upvotes: 4