美元符号 ($)

使用美元符号匹配位于字符串末尾的前一个相邻字符。

例如,`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$

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