Reputation: 7753
I am trying to remove either « or » from a string to leave the remainding text in javaScript.
Have tried this to no effect:
$('body').delegate('.SearchPagination > a', 'click', function(e){
e.preventDefault();
var $this = $(this),
txt = $this.text().toLowerCase(),
txt = txt.replace(/«|»/g, ''),
txt = $.trim(txt),
page = '&page=';
console.log(txt);
if (txt === 'next' || txt === 'previous'){
// get the current page value
var active = $this.parent().find('.active').txt();
if (txt === 'next'){
// add one
page += (active + 1);
} else if (txt === 'previous'){
// subtract one
page += (active - 1);
}
} else {
// invoke search with the page number
page += txt;
}
console.log(page);
//icisSite.icisSearch.search(page);
});
Upvotes: 1
Views: 5416
Reputation: 544
Instead of using « in the regex, try copy-pasting the left arrow character displayed in the browser - i.e. the « sign. I tried that and it was replaced correctly.
So your regex should look like -
txt = txt.replace(/«|»/g, '')
Upvotes: 4
Reputation: 76880
Have you tried:
txt = txt.replace('«','').replace('»', '');
But i don't think this is the point since your regexp is correct, so, just in case (you regulare expression seems correct to me) , are you shure that when you get the text the htmlentities are encoded in the first place?Maybe the page is in UTF-8 and the entities are not encoded but displayed withouth encoding
Upvotes: 1