我在网络应用中使用自动填充器jquery-textcomplete。它适用于英语和俄语字母。但它不适用于某些特殊字母,例如“ҷ”。
代码:
$('.form-control').textcomplete([{
words: ['тоҷик', 'ҷаҳон', 'english'],
match: /(^|[^\wа-яёҷ])([\wа-яё]{2,})$/i,
search: function(term, callback) {
callback($.map(this.words, function(word) {
return word.indexOf(term) === 0 ? word : null;
}));
},
index: 2,
replace: function(word) {
return '$1' + word + ' ';
}
}]);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.textcomplete/1.8.4/jquery.textcomplete.min.js"></script>
<textarea class="form-control"></textarea>
此处'тоҷик'
和'english'
这两个词正在运作,但'ҷаҳон'
却没有。我该如何解决这个问题?
我需要以下信件才能发挥作用:ғ,ӯ,қ,ҳ,ҷ,ӣ
和а-я
。
答案 0 :(得分:2)
Similar question已经回答了。
$('#textcomplete').textcomplete([{
words: ['тоҷик', 'ҷаҳон', 'english'],
match: /(^|\S*)([^\u0000-\u007f]{2,}|\w{2,})$/,
search: function(term, callback) {
callback($.map(this.words, function(word) {
return word.indexOf(term) === 0 ? word : null;
}));
},
index: 2,
replace: function(word) {
return word + ' ';
}
}]);
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.textcomplete/1.8.4/jquery.textcomplete.min.js"></script>
<textarea id="textcomplete"></textarea>
&#13;