文字列から«または»のいずれかを削除して、残りのテキストをjavaScriptに残そうとしています。«または»をJavaScriptの文字列から削除する
は効果なしにこれを試してみました:
txt = txt.replace('«','').replace('»', '');
をしかし、私はあなたの正規表現が正確であるため、これがポイントだと思いますので、念のためにしないでください:
$('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);
});
: ' "«テスト»" .replace(/ « | »/gで、 '')'。あなたの正規表現は間違っていません。 – pimvdb