I’m trying to split a string based upon the middle dot. For some reason, it’s not recognizing it. I can use a “pipe” character so I know everything else is working, but not the middle dot. Do I need to escape the middle dot? If so, how?
Javascript
var sTags = $(this).text();
// alert(sTags);
sSplitTags = sTags.split(' | ');
// Split isn't recognizing the middot
// var sSplitTags = sTags.split(' · ');
// var sSplitTags = sTags.split(' · ');
// var sSplitTags = sTags.split(' · ');
alert(sSplitTags[0]);
HTML
<div>Upscale · Gadget</div>
<div>Expensive · Widget</div>
<div>Expensive · Widget</div>
Thanks in advance!
' \267 'Should be what you’re looking for. Javascript uses an octal encoding for special characters that differs from the html/css encoding syntax.Here’s a site with a nice lookup table: http://www.evotech.net/blog/2007/04/named-html-entities-in-numeric-order/
-EDIT-
ruakh brought up this version of
' \u00B7 'which is also just as valid. You’ll notice on the page that there is a column for hex codes and for middle dot it isB7. In css you would write\00B7but in javascript we need to qualify that this is not an octal by appending the little ‘u’ to the front and you’d end up with\u00B7'.