aboutsummaryrefslogtreecommitdiffstats
path: root/doc/regexp.rdoc
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2022-04-16 15:20:03 -0500
committerGitHub <noreply@github.com>2022-04-16 15:20:03 -0500
commit2b4b513ef046c25c0a8d3d7b10a0566314b27099 (patch)
tree6e0982719d6cae1d9777e92dbb0e7a085764aa8b /doc/regexp.rdoc
parentbde06ce33a3d881b4198aeb0d8c946ed51f3aab6 (diff)
downloadruby-2b4b513ef046c25c0a8d3d7b10a0566314b27099.tar.gz
[DOC] Enhanced RDoc for Regexp (#5812)
Treats: #fixed_encoding? #hash #== #=~ #match #match? Also, in regexp.rdoc: Changes heading from 'Special Global Variables' to 'Regexp Global Variables'. Add tiny section 'Regexp Interpolation'.
Diffstat (limited to 'doc/regexp.rdoc')
-rw-r--r--doc/regexp.rdoc10
1 files changed, 9 insertions, 1 deletions
diff --git a/doc/regexp.rdoc b/doc/regexp.rdoc
index b8efc7e3d4..2b6a870026 100644
--- a/doc/regexp.rdoc
+++ b/doc/regexp.rdoc
@@ -30,6 +30,13 @@ _s_ followed by the letter _t_, so it matches _haystack_, also.
Note that any Regexp matching will raise a RuntimeError if timeout is set and
exceeded. See "Timeout" section in detail.
+== \Regexp Interpolation
+
+A regexp may contain interpolated strings; trivially:
+
+ foo = 'bar'
+ /#{foo}/ # => /bar/
+
== <tt>=~</tt> and Regexp#match
Pattern matching may be achieved by using <tt>=~</tt> operator or Regexp#match
@@ -672,9 +679,10 @@ 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
+== \Regexp Global Variables
Pattern matching sets some global variables :
+
* <tt>$~</tt> is equivalent to Regexp.last_match;
* <tt>$&</tt> contains the complete matched text;
* <tt>$`</tt> contains string before match;