A: 

Try .filter.

I found another question on SO with pertinent info:

http://stackoverflow.com/questions/345194/regular-expression-matching-in-jquery

Josh
+1  A: 
$('div:contains("£")').each( function() {
     var text = $(this).html();
     if (text && text.match(/\s*£\s*/)) {
        $(this).addClass('pound');
     }
});
tvanfosson
Thanks for the reply and code, but no joy I'm afraid :(
Keith Donegan
You might need to adjust the regular expression. It's possible that you'll have to search for the unicode value associated with the pound sign. Try stepping the code through the firefox/firebug debugger and looking at the values of the innerHTML of each of the divs. Remove the contains() if it doesn't seem to be selecting the divs you want so you can get a better idea of what javascript sees inside them.
tvanfosson
+3  A: 

I believe the problem is that the browser is transforming the HTML escape characters, so you need to look for the actual character... I tested this and it works

$(document).ready(function(){
 $('div').each(function(){
  if ($(this).html() == "£"){
   $(this).addClass("pound");
  }
 })
})
fudgey
This kind of makes sense.. `£` is a HTML escape sequence, not a Javascript one.. It seems sensible Javascript would see the actual pound symbol, although it would make sense either way I guess..
dbr
A: 

tvanfosson's code allows for whitespace either side of the £ sign, but the regular expression could do with a bit of modification:

$('div:contains("£")').each( function() {
    var text = $(this).html();
    if (text && text.match(/^\s*£\s*$/)) {
        $(this).addClass('pound');
        }
    });

note the '^' and '$' indicating the beginning and end of the string.

Rowan