summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-08-28 11:40:56 -0700
committerJeremy Evans <code@jeremyevans.net>2019-08-28 11:50:33 -0700
commitcd0e208963bdf9ee2fec30e83bdc8f6bc77a7b8d (patch)
treeb968164b415893e52490bcb8f2496f8ad0fc7197 /doc
parente82719c6511cf00bd4b92759ba0197108cfad0cc (diff)
Document {n}? regexp pattern is optional and not non-greedy [ci skip]
While not consistent with {n,}?, {,m}?, and {n,m}?, it is arguably more useful, as otherwise the ? would have no effect. Fixes [Bug #15583]
Diffstat (limited to 'doc')
-rw-r--r--doc/regexp.rdoc7
1 files changed, 5 insertions, 2 deletions
diff --git a/doc/regexp.rdoc b/doc/regexp.rdoc
index 40c73952d6..20e8e3634a 100644
--- a/doc/regexp.rdoc
+++ b/doc/regexp.rdoc
@@ -189,8 +189,11 @@ At least one uppercase character ('H'), at least one lowercase character
Repetition is <i>greedy</i> by default: as many occurrences as possible
are matched while still allowing the overall match to succeed. By
contrast, <i>lazy</i> matching makes the minimal amount of matches
-necessary for overall success. A greedy metacharacter can be made lazy by
-following it with <tt>?</tt>.
+necessary for overall success. Most greedy metacharacters can be made lazy
+by following them with <tt>?</tt>. For the <tt>{n}</tt> pattern, because
+it specifies an exact number of characters to match and not a variable
+number of characters, the <tt>?</tt> metacharacter instead makes the
+repeated pattern optional.
Both patterns below match the string. The first uses a greedy quantifier so
'.+' matches '<a><b>'; the second uses a lazy quantifier so '.+?' matches