* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
3.0 KiB
3.0 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db7367417b2b2512b9f | Match All Letters and Numbers | 1 | 匹配所有字母和数字 |
Description
[az]
搜索字母表中的所有字母。这种字符类很常见,它有一个快捷方式,虽然它还包含一些额外的字符。 JavaScript中与字母表匹配的最接近的字符类是\w
。此快捷方式等于[A-Za-z0-9_]
。此字符类匹配大写和小写字母加数字。注意,此字符类还包括下划线字符( _
)。 让longHand = / [A-Za-z0-9 _] + /;这些快捷方式字符类也称为
让shortHand = / \ w + /;
让数字=“42”;
let varNames =“important_var”;
longHand.test(数字); //返回true
shortHand.test(数字); //返回true
longHand.test(varNames); //返回true
shortHand.test(varNames); //返回true
shorthand character classes
。 Instructions
\w
来计算各种引号和字符串中的字母数字字符数。 Tests
tests:
- text: 你的正则表达式应该使用全局标志。
testString: assert(alphabetRegexV2.global);
- text: 你的正则表达式应该使用速记字符
testString: assert(/\\w/.test(alphabetRegexV2.source));
- text: 你的正则表达式应该在<code>"The five boxing wizards jump quickly."</code>找到31个字母数字字符<code>"The five boxing wizards jump quickly."</code>
testString: assert("The five boxing wizards jump quickly.".match(alphabetRegexV2).length === 31);
- text: 你的正则表达式应该在<code>"Pack my box with five dozen liquor jugs."</code>找到32个字母数字字符<code>"Pack my box with five dozen liquor jugs."</code>
testString: assert("Pack my box with five dozen liquor jugs.".match(alphabetRegexV2).length === 32);
- text: 你的正则表达式应该在<code>"How vexingly quick daft zebras jump!"</code>找到30个字母数字字符<code>"How vexingly quick daft zebras jump!"</code>
testString: assert("How vexingly quick daft zebras jump!".match(alphabetRegexV2).length === 30);
- text: 你的正则表达式应该在<code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>找到36个字母数字字符<code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>
testString: assert("123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.".match(alphabetRegexV2).length === 36);
Challenge Seed
let quoteSample = "The five boxing wizards jump quickly.";
let alphabetRegexV2 = /change/; // Change this line
let result = quoteSample.match(alphabetRegexV2).length;
Solution
// solution required