freeCodeCamp/guide/chinese/certifications/javascript-algorithms-and-d.../regular-expressions/match-single-character-with.../index.md

901 B
Raw Blame History

title localeTitle
Match Single Character with Multiple Possibilities 将单个角色与多种可能性相匹配

将单个角色与多种可能性相匹配

提取

使用match方法您可以提取与正则表达式匹配的字符串部分。在此挑战中您将从提供的字符串中提取元音“aeiou”。

提示1

您是否尝试使用test方法请记住此方法仅返回True或False - 我们需要从字符串中提取元音。

提示2

您是否尝试过不使用逗号的“[]”字符大小写匹配?即[abcd] vs [abcd]

剧透警报 - 提前解决!

let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it."; 
 let vowelRegex = /[aeiou]/ig; // Change this line 
 let result = quoteSample.match(vowelRegex); // Change this line