diff options
author | Burdette Lamar <BurdetteLamar@Yahoo.com> | 2022-04-16 15:20:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-16 15:20:03 -0500 |
commit | 2b4b513ef046c25c0a8d3d7b10a0566314b27099 (patch) | |
tree | 6e0982719d6cae1d9777e92dbb0e7a085764aa8b /doc/regexp.rdoc | |
parent | bde06ce33a3d881b4198aeb0d8c946ed51f3aab6 (diff) |
[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'.
Notes
Notes:
Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
Diffstat (limited to 'doc/regexp.rdoc')
-rw-r--r-- | doc/regexp.rdoc | 10 |
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; |