freeCodeCamp/guide/chinese/certifications/javascript-algorithms-and-d.../regular-expressions/ignore-case-while-matching/index.md

640 B
Raw Blame History

title localeTitle
Ignore Case While Matching 匹配时忽略大小写

匹配时忽略大小写

创建正则表达式时,您可能希望匹配拼写相同但字符串不同的字符串部分。为此,您将i标志添加到正则表达式的末尾。在这个挑战中,你就是这么做的。

提示1

修改正则表达式使其检测到“freeCodeCamp”“FREECODECAMP”和“FrEeCoDeCaMp”。也许使用i旗可能有帮助吗?

剧透警报 - 提前解决!

let myString = "freeCodeCamp"; 
 let fccRegex = /freeCodeCamp/i; 
 let result = fccRegex.test(myString);