freeCodeCamp/guide/chinese/certifications/javascript-algorithms-and-d.../regular-expressions/using-the-test-method/index.md

548 B
Raw Blame History

title localeTitle
Using the Test Method 使用测试方法

使用测试方法

在这个挑战,你检查是否字符串包含一定的“正则表达式”,或正则表达式 REG ular pressions。您将使用test()方法来执行此操作。

提示1

myRegex上调用测试方法。您认为这个论点是什么?

剧透警报 - 提前解决!

let myString = "Hello, World!"; 
 let myRegex = /Hello/; 
 let result = myRegex.test(myString); // Change this line