[jQuery] Simple autolink and highlight

[jQuery] Simple autolink and highlight

Some more simple stuff, might be useful for others.
Example
http://kawika.org/jquery/autolink/
Code
jQuery.fn.highlight = function (text, o) {
    return this.each( function(){
        var replace = o || '<span class="highlight">$1</span>';
        $(this).html( html.replace( new
RegExp('('+text+'(?![\\w\\s?&.\\/;#~%"=-]*>))', "ig"), replace) );
    });
}
jQuery.fn.autolink = function () {
    return this.each( function(){
        var re =
/((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g;
        $(this).html( $(this).html().replace(re, '<a href="$1">$1</a> ') );
    });
}
jQuery.fn.mailto = function () {
    return this.each( function() {
        var re =
/(([a-z0-9*._+]){1,}\@(([a-z0-9]+[-]?){1,}[a-z0-9]+\.){1,}([a-z]{2,4}|museum)(?![\w\s?&.\/;#~%"=-]*>))/g
        $(this).html( $(this).html().replace( re, '<a href="mailto:$1">$1</a>'
) );
    });
}
Usage
$(document).ready( function () {
    $("body").autolink();
    $("body").mailto();
    $("body").highlight( "highlight" );
    $("body").highlight( "word", "$1 <img src=\"0034_up_not_down.gif\" />" );
});
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/