jQuery: RegExp for all occurances; Wrap all © and ® with HTML

March 26th, 2010

This script will find all © and ® on a page and wrap them a span around them with a “copy” or “reg” class accordingly.

.copy, .reg {font-size:xx-small;vertical-align:text-top;}

var copy = new RegExp(‘\u00a9′,’g’);
var reg = new RegExp(‘\u00ae’,’g’);
var newBody = $(‘body’).html().replace(copy, ‘<span class=”copy”>&copy;</span>’).replace(reg, ‘<span class=”reg”>&reg;</span>’);

Tags: , , , ,

Comments are closed.

Comments have been closed for this post. If you would like to ask a question or need help, please post in the forums.