weixiangzhe
2021-08-16 09:07:48 +08:00
x(?=y) 先行断言 Lookahead assertion: (positive lookahead) Matches “x” only if “x” is followed by “y”. For example, /Jack(?=Sprat)/ matches “Jack” only if it is followed by “Sprat”. `/Jack(?=Sprat
x(?!y) 正向否定查找 Negative lookahead assertion: Matches “x” only if “x” is not followed by “y”. For example, /\d+(?!\.)/ matches a number only if it is not followed by a decimal point. /\d+(?!\.)/.exec('3.141') matches “141” but not “3”.
(?<=y)x 后行断言 Lookbehind assertion: Matches “x” only if “x” is preceded by “y”. For example, /(?<=Jack)Sprat/ matches “Sprat” only if it is preceded by “Jack”. `/(?<=Jack
(?<!y)x 反向否定查找 Negative lookbehind assertion: Matches “x” only if “x” is not preceded by “y”. For example, /(?<!-)\d+/ matches a number only if it is not preceded by a minus sign. /(?<!-)\d+/.exec('3') matches “3”. /(?<!-)\d+/.exec('-3') match is not found because the number is preceded by the minus sign.
__
话说这些翻译中文的确实有点难理解😂