javascript - javascript过滤字符串数组,匹配不区分大小写的子字符串
问题描述
我有一个由某个字符串过滤的名称数组。如何匹配包含此字符串但不区分大小写的所有名称?
this.employeeDisplayList = this.employeeList.filter(e => e.employeeName.includes(this.searchStr));
解决方案
this.employeeDisplayList = this.employeeList.filter(e => {
const emp = e.employeeName.toLowerCase();
const str = this.searchStr.toLowerCase();
return emp.includes(str);
});
推荐阅读
- docker - Kubelet 在 NFS 持久卷中缓存文件的本地副本
- python - Manim - BrokenPipeError: [Errno 32] 断管
- java - REST Api - JSON - “无法反序列化 START_ARRAY 令牌中的对象实例”
- python - 转储到 JSON 时如何控制格式?
- sql - 从 Visual Studio 项目中读取 SQL 变量
- python - 将 sklearn 糖尿病数据集转换为 pandas DataFrame
- xml - 带有viewpager的布局底部的静态按钮
- c# - Azure WebJobs 从静态函数中访问配置
- jquery - Fullcalendar V4 - 根据条件隐藏下一个和上一个选项?
- google-bigquery - 如何在 BigQuery 的列中创建重复的数字序列