美元符号 ($)

使用美元符号可匹配位于字符串结尾的相邻字符。

例如,`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 匹配的细分、过滤条件或目标步骤。例如,如果您要测试网页的新 HTM 版本与旧 HTML 版本相比的效果,可以使用以下正则表达式分别识别这两个版本:

  • email-signup\.htm$
  • email-signup\.html$

使用反斜杠转义点,确保按字面意思解释点。