搜索小写和大写字符
我的 JSON 数据
[
{"lastName":"Noyce","gender":"Male","patientID":19389,"firstName":"Scott","age":"53Y,"},
{"lastName":"noyce724","gender":"Male","patientID":24607,"firstName":"rita","age":"0Y,"}
]
var searchBarInput = TextInput.value;
var results = []; // initialize array of results
for (var i = 0; i < recentPatientsList.length; ++i) {
if (recentPatientsList[i].lastName.indexOf(searchBarInput) == 0) {
results.push(recentPatientsList[i].lastName);
}
}
alert('Results: ' + results.toString());
得到了结果,但当我搜索以单词开头的字符时,我希望它能够匹配大写和小写。
My JSON data
[
{"lastName":"Noyce","gender":"Male","patientID":19389,"firstName":"Scott","age":"53Y,"},
{"lastName":"noyce724","gender":"Male","patientID":24607,"firstName":"rita","age":"0Y,"}
]
var searchBarInput = TextInput.value;
var results = []; // initialize array of results
for (var i = 0; i < recentPatientsList.length; ++i) {
if (recentPatientsList[i].lastName.indexOf(searchBarInput) == 0) {
results.push(recentPatientsList[i].lastName);
}
}
alert('Results: ' + results.toString());
I get the result, but i want it for both matching uppercase and lowercase when i search for a character which starts in the word.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在两个字符串上使用
toUpperCase
You can use
toUpperCase
on both of the strings