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 greedy by default: as many occurrences as possible are matched while still allowing the overall match to succeed. By contrast, lazy matching makes the minimal amount of matches -necessary for overall success. A greedy metacharacter can be made lazy by -following it with ?. +necessary for overall success. Most greedy metacharacters can be made lazy +by following them with ?. For the {n} pattern, because +it specifies an exact number of characters to match and not a variable +number of characters, the ? metacharacter instead makes the +repeated pattern optional. Both patterns below match the string. The first uses a greedy quantifier so '.+' matches ''; the second uses a lazy quantifier so '.+?' matches