aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2022-04-15 13:31:15 -0500
committerGitHub <noreply@github.com>2022-04-15 13:31:15 -0500
commite021754db013ca9cd6dbd68b416425b32ee81490 (patch)
treea8dfc116cf5a5f80891a6b62085d844f1a3c56eb /doc
parent7f81f335478a3ca873f34e3bc0af6927819d3e84 (diff)
downloadruby-e021754db013ca9cd6dbd68b416425b32ee81490.tar.gz
[DOC] Enhanced RDoc for Regexp (#5807)
Treats: #source #inspect #to_s #casefold? #options #names #named_captures
Diffstat (limited to 'doc')
-rw-r--r--doc/regexp.rdoc12
1 files changed, 6 insertions, 6 deletions
diff --git a/doc/regexp.rdoc b/doc/regexp.rdoc
index 65d8cd46fa..b8efc7e3d4 100644
--- a/doc/regexp.rdoc
+++ b/doc/regexp.rdoc
@@ -35,7 +35,7 @@ exceeded. See "Timeout" section in detail.
Pattern matching may be achieved by using <tt>=~</tt> operator or Regexp#match
method.
-=== <tt>=~</tt> operator
+=== <tt>=~</tt> Operator
<tt>=~</tt> is Ruby's basic pattern-matching operator. When one operand is a
regular expression and the other is a string then the regular expression is
@@ -54,7 +54,7 @@ Using <tt>=~</tt> operator with a String and Regexp the <tt>$~</tt> global
variable is set after a successful match. <tt>$~</tt> holds a MatchData
object. Regexp.last_match is equivalent to <tt>$~</tt>.
-=== Regexp#match method
+=== Regexp#match Method
The #match method returns a MatchData object:
@@ -193,7 +193,7 @@ At least one uppercase character ('H'), at least one lowercase character
"Hello".match(/[[:upper:]]+[[:lower:]]+l{2}o/) #=> #<MatchData "Hello">
-=== Greedy match
+=== Greedy Match
Repetition is <i>greedy</i> by default: as many occurrences as possible
are matched while still allowing the overall match to succeed. By
@@ -211,7 +211,7 @@ Both patterns below match the string. The first uses a greedy quantifier so
/<.+>/.match("<a><b>") #=> #<MatchData "<a><b>">
/<.+?>/.match("<a><b>") #=> #<MatchData "<a>">
-=== Possessive match
+=== Possessive Match
A quantifier followed by <tt>+</tt> matches <i>possessively</i>: once it
has matched it does not backtrack. They behave like greedy quantifiers,
@@ -256,7 +256,7 @@ this backreference when doing substitution:
"The cat sat in the hat".gsub(/[csh]at/, '\0s')
# => "The cats sats in the hats"
-=== Named captures
+=== Named Captures
Capture groups can be referred to by name when defined with the
<tt>(?<</tt><i>name</i><tt>>)</tt> or <tt>(?'</tt><i>name</i><tt>')</tt>
@@ -672,7 +672,7 @@ regexp's encoding can be explicitly fixed by supplying
# raises Encoding::CompatibilityError: incompatible encoding regexp match
# (ISO-8859-1 regexp with UTF-8 string)
-== Special global variables
+== Special Global Variables
Pattern matching sets some global variables :
* <tt>$~</tt> is equivalent to Regexp.last_match;