Is it possible to select only part of a string using jquery? For example I have a text
Metuentes igitur idem latrones Lycaoniam magna parte campestrem&l
There is no way to do this with pure jQuery. You could do this instead :
var search = 'Lycaoniam';
var orig = $('p').html();
var highlighted = orig.replace(new RegExp(
search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'gi'
), '$&');
$('p').html(highlighted);
To revert back to the original text :
$('p').html(orig);
The search.replace(...) part allows to deal with special chars : http://jsfiddle.net/wared/TPg9p/.