jquery - Find text in a string and prependTo somewhere else -
i trying find text regex /\w*http:[/][/]bit.ly[/]\w*/ig
find string , pull out, moving <span>
tag, or @ end of <p>
tag?
<p class="regex">text before http://bit.ly/wtgahsu sometext here, doesn't matter how long is.... <span></span></p>
$("p:regex('(\w*http:[/][/]bit.ly[/]\w*)')").addclass('active');
above have far (just selecting p), i've tried .highlight()
im not sure grab text , move it, appreciated.
thanks
you use this:
$("p.regex").each ( function () { var jthis = $(this); var newsrc = jthis.text ().replace (/^(.*)(https?\:\/\/bit\.ly\/\w+)(.*)$/i, '$1$3<span>$2</span>'); jthis.html (newsrc); } );
note version assumes 1 link, max, per paragraph.
Comments
Post a Comment