\d ,小写d 。这等于字符类[0-9] ,它查找0到9之间任意数字的单个字符。 \d来计算电影标题中的位数。写出的数字(“六”而不是六)不计算在内。 "9"找到1位数。
testString: 'assert("9".match(numRegex).length == 1, "Your regex should find 1 digit in "9".");'
- text: 你的正则表达式应该在"Catch 22"找到2位数字。
testString: 'assert("Catch 22".match(numRegex).length == 2, "Your regex should find 2 digits in "Catch 22".");'
- text: 你的正则表达式应该在"101 Dalmatians"找到3位数字。
testString: 'assert("101 Dalmatians".match(numRegex).length == 3, "Your regex should find 3 digits in "101 Dalmatians".");'
- text: '你的正则表达式应该在"One, Two, Three"找不到数字。'
testString: 'assert("One, Two, Three".match(numRegex) == null, "Your regex should find no digits in "One, Two, Three".");'
- text: 您的正则表达式应该在"21 Jump Street"找到2位数字。
testString: 'assert("21 Jump Street".match(numRegex).length == 2, "Your regex should find 2 digits in "21 Jump Street".");'
- text: '你的正则表达式应该在"2001: A Space Odyssey"找到4位数字。'
testString: 'assert("2001: A Space Odyssey".match(numRegex).length == 4, "Your regex should find 4 digits in "2001: A Space Odyssey".");'
```