From 859d8e4f0b558a0686f50617edc005519bf59116 Mon Sep 17 00:00:00 2001 From: Xinpeng Wei Date: Fri, 2 Dec 2022 17:16:09 +0800 Subject: [PATCH] fix: make the meaning of ^ and $ more precise (#1905) * make the meaning of ^ and $ more clear ^ and $ work differently in multi-line pattern which are different from \A and \Z. * Update regexp.md Co-authored-by: Rico Sta. Cruz --- regexp.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/regexp.md b/regexp.md index 30bcd8ac2..212bf4815 100644 --- a/regexp.md +++ b/regexp.md @@ -35,18 +35,20 @@ description: | ### Anchors -| Pattern | Description | -| ------- | ----------------------- | -| `\G` | Start of match | -| `^` | Start of string | -| `$` | End of string | -| `\A` | Start of string | -| `\Z` | End of string | -| `\z` | Absolute end of string | -| `\b` | A word boundry | -| `\B` | Non-word boundry | -| `^abc` | Start with `abc` | -| `abc$` | End with `abc` | +| Pattern | Description | +| ------- | ---------------------- | +| `\G` | Start of match | +| `^` | Start of string \* | +| `$` | End of string \* | +| `\A` | Start of string | +| `\Z` | End of string | +| `\z` | Absolute end of string | +| `\b` | A word boundry | +| `\B` | Non-word boundry | +| `^abc` | Start with `abc` | +| `abc$` | End with `abc` | + +For multiline patterns (`m` flag), `^` and `$` will act as start and end of line. ### Escaped characters