使用美元符号匹配位于字符串结尾的前一个相邻字符。
例如,`end$` 与以下内容匹配:
- Temporarily suspend
- We're going off the deep end
- Match the characters that prepend
但是,`end$` 与以下内容不匹配:
- Temporarily suspend.
- We're going off the deep end.
- Match the characters that prepend.
前三行都以 nd. 结尾,而不是以您使用正则表达式匹配的 end 字符结尾。
使用此类正则表达式创建与 URI 匹配的细分受众群、过滤条件或目标步骤。例如,如果您要测试网页的新 HTML 版本与旧 HTML 版本相比的效果,可以使用以下正则表达式分别识别这些版本:
- email-signup\.htm$
- email-signup\.html$
使用 反斜杠 转义英文句点,确保按字面意思解释英文句点。