Last active
September 12, 2020 14:01
-
-
Save peterlikesnoodles/e0c1cbf598252190bcef6106c92ff3d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* str 结构是 `${str1} ${str2}`. | |
* 二个字符串用空格分开。 | |
* | |
* str1 描述以下3种规则: | |
* - + 匹配单一写了字符 | |
* - * 匹配3个连续的相同字符 | |
* - *{N} 匹配 N 个连续的相同字符(比如 *{12} 匹配12个相同字符) | |
* @returns str2 是否完全符合 str1 的格式表示 | |
*/ | |
const test = (str) => { | |
// | |
} | |
const print = (str, expected) => { | |
const testResult = test(str) | |
console.log('[testing]', str, testResult === expected ? '√' : 'x') | |
} | |
console.log('exactMatch evaluating:') | |
print('+ a', true) | |
print('+ ab', false) | |
print('* 333', true) | |
print('* 334', false) | |
print('* 3334', false) | |
print('+**{4} abbbcccc', true) | |
print('+**{4} abbcdddd', false) | |
print('+**{4} abbbccc', false) | |
print('+**{4} abbbccccc', false) | |
print('+**{4}+ abbbccccc', true) | |
print('+**{4}+ abbbcccdd', false) | |
print('+*{12} abbbbbbbbbbbb', true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment