places.json 如下
[{"CC":"XNR","CN":"Aabenraa"},{"CC":"AAH","CN":"Aachen"},{"CC":"XOA","CN":"Aalbaek"},{"CC":"AAL","CN":"Aalborg"},{"CC":"QFA","CN":"Aalsmeer"}]
CN 代表contry代码, CN 代表contry名称
$(".typeahead").autocomplete({
source: function (request, response) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
$.ajax({
url: "places.json",
dataType: "json",
success: function (data) {
response($.map(data, function(v,i){
var text = v.CN;
if ( text && ( !request.term || matcher.test(text) ) ) {
return {
label: v.CN.concat(' (',v.CC,')'),
value: v.CC
};
}
}));
}
});
}
});
如何实施我的代码以搜索国家/地区名称和国家/地区代码
答案 0 :(得分:0)
您只在std::string s1 = string("Hello");
if ( _stricmp(s1.c_str(), "HELLO") == 0)
std::cout << "The string are equals.";
中查看国家/地区名称。你也应该检查国家代码
更新以下if(条件)
matcher.test()