ruby-changes:63083
From: Burdette <ko1@a...>
Date: Fri, 25 Sep 2020 08:38:30 +0900 (JST)
Subject: [ruby-changes:63083] 83ff0f74bf (master): Enhanced RDoc for String#match? (#3576)
https://git.ruby-lang.org/ruby.git/commit/?id=83ff0f74bf From 83ff0f74bf69650754cac020bcd4ff9adbba877e Mon Sep 17 00:00:00 2001 From: Burdette Lamar <BurdetteLamar@Y...> Date: Thu, 24 Sep 2020 18:38:11 -0500 Subject: Enhanced RDoc for String#match? (#3576) * Enhanced RDoc for String#match? diff --git a/string.c b/string.c index fa14888..e2c7bfb 100644 --- a/string.c +++ b/string.c @@ -3860,6 +3860,9 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L3860 * 'foo' =~ /o/ # => 1 * 'foo' =~ /x/ # => nil * + * Note: also updates + * {Regexp-related global variables}[Regexp.html#class-Regexp-label-Special+global+variables]. + * * If the given +object+ is not a \Regexp, returns the value * returned by <tt>object =~ self</tt>. * @@ -3898,6 +3901,9 @@ static VALUE get_pat(VALUE); https://github.com/ruby/ruby/blob/trunk/string.c#L3901 * * Returns a \Matchdata object (or +nil+) based on +self+ and the given +pattern+. * + * Note: also updates + * {Regexp-related global variables}[Regexp.html#class-Regexp-label-Special+global+variables]. + * * - Computes +regexp+ by converting +pattern+ (if not already a \Regexp). * regexp = Regexp.new(pattern) * - Computes +matchdata+, which will be either a \MatchData object or +nil+ @@ -3937,19 +3943,25 @@ rb_str_match_m(int argc, VALUE *argv, VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L3943 /* * call-seq: - * str.match?(pattern) -> true or false - * str.match?(pattern, pos) -> true or false - * - * Converts _pattern_ to a +Regexp+ (if it isn't already one), then - * returns a +true+ or +false+ indicates whether the regexp is - * matched _str_ or not without updating <code>$~</code> and other - * related variables. If the second parameter is present, it - * specifies the position in the string to begin the search. - * - * "Ruby".match?(/R.../) #=> true - * "Ruby".match?(/R.../, 1) #=> false - * "Ruby".match?(/P.../) #=> false - * $& #=> nil + * string.match?(pattern, offset = 0) -> true or false + * + * Returns +true+ or +false+ based on whether a match is found for +self+ and +pattern+. + * + * Note: does not update + * {Regexp-related global variables}[Regexp.html#class-Regexp-label-Special+global+variables]. + * + * Computes +regexp+ by converting +pattern+ (if not already a \Regexp). + * regexp = Regexp.new(pattern) + * + * Returns +true+ if <tt>self+.match(regexp)</tt> returns a \Matchdata object, + * +false+ otherwise: + * 'foo'.match?(/o/) # => true + * 'foo'.match?('o') # => true + * 'foo'.match?(/x/) # => false + * + * If \Integer argument +offset+ is given, the search begins at index +offset+: + * 'foo'.match?('f', 1) # => false + * 'foo'.match?('o', 1) # => true */ static VALUE -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/