るりまサーチ

最速Rubyリファレンスマニュアル検索!
904件ヒット [201-300件を表示] (0.066秒)

別のキーワード

  1. string []=
  2. string slice
  3. string []
  4. string slice!
  5. string gsub!

ライブラリ

モジュール

キーワード

検索結果

<< < 1 2 3 4 5 ... > >>

Scanf::FormatString#last_match_tried (9101.0)

@todo

@todo

Scanf::FormatString#matched_count (9100.0)

@todo

@todo

StringScanner#matchedsize -> Integer | nil (9100.0)

StringScanner#matched_size と同じです。

...
String
Scanner#matched_size と同じです。

このメソッドは は将来のバージョンで削除される予定です。
代わりに StringScanner#matched_size を使ってください。

@see StringScanner#matched_size...

Regexp.last_match(nth) -> String | nil (6274.0)

整数 nth が 0 の場合、マッチした文字列を返します ($&)。それ以外では、nth 番目の括弧にマッチ した部分文字列を返します($1,$2,...)。 対応する括弧がない場合やマッチしなかった場合には nil を返し ます。

..."
p Regexp.last_match # => #<MatchData:0x4599e58>
p Regexp.last_match(0) # => "ab"
p Regexp.last_match(1) # => "a"
p Regexp.last_match(2) # => "b"
p Regexp.last_match(3) # => nil
//}

正規表現全体がマッチしなかった場合、引数なしの
Regexp.last_match はnil を返...
...すため、
last_match[1] の形式では例外 NoMethodError が発生します。
対して、last_match(1) は nil を返します。

//emlist[例][ruby]{
str = "This is Regexp"
/That is Regexp/ =~ str
p Regexp.last_match # => nil
begin
p Regexp.last_match[1] # 例外が発生する
rescue...
...puts $! # => undefined method `[]' for nil:NilClass
end
p Regexp.last_match(1) # => nil
//}

@param nth 整数を指定します。
整数 nth が 0 の場合、マッチした文字列を返します。それ以外では、nth 番目の括弧にマッチした部分文字列を返します。...

Regexp.last_match -> MatchData (6244.0)

カレントスコープで最後に行った正規表現マッチの MatchData オ ブジェクトを返します。このメソッドの呼び出しは $~ の参照と同じです。

... MatchData オ
ブジェクトを返します。このメソッドの呼び出しは $~
の参照と同じです。

//emlist[例][ruby]{
/(.)(.)/ =~ "ab"
p Regexp.last_match # => #<MatchData:0x4599e58>
p Regexp.last_match[0] # => "ab"
p Regexp.last_match[1] # => "a"
p Regexp.last_match[2]...
...# => "b"
p Regexp.last_match[3] # => nil
//}...

絞り込み条件を変える

REXML::Entity.matches?(string) -> bool (6223.0)

string が実体宣言の文法に従う文字列であれば真を返します。

...string が実体宣言の文法に従う文字列であれば真を返します。

@param string 判定対象の文字列

//emlist[][ruby]{
require 'rexml/document'

p REXML::Entity.matches?('<!ENTITY s "seal">') # => true
p REXML::Entity.matches?('<!ENTITY % s "seal">') # => true
p REXML::Entity....
...matches?('<!ELEMENT br EMPTY >') # => false
//}...

Kernel$$MATCH -> String | nil (6208.0)

$& の別名

...$& の別名

require "English"

str = 'hoge,foo,bar,hee,hoo'

/(foo|bar)/ =~ str
p $MATCH #=> "foo"...

Kernel$$LAST_PAREN_MATCH -> String | nil (6202.0)

$+ の別名

$+ の別名

require "English"

r1 = Regexp.compile("<img src=(http:.+?)>")
r2 = Regexp.compile("<a href=(http|ftp).+?>(.+?)</a>")

while line = DATA.gets
[ r1, r2 ].each {|rep|
rep =~ line
p $+
}
end
__END__
<tr> <td><img src=http://localhost/a.jpg></td> <td>ikkou</td>...

Gem::GemPathSearcher#matching_files(spec, path) -> [String] (6201.0)

与えられた spec に path が含まれている場合、その path のリストを返します。

与えられた spec に path が含まれている場合、その path のリストを返します。

@param spec Gem::Specification のインスタンスを指定します。

@param path 探索対象のパスを指定します。

Kernel$$POSTMATCH -> String | nil (6201.0)

$' の別名

...$' の別名

require "English"

str = 'hoge,foo,bar,hee,hoo'

/foo/ =~ str
p $POSTMATCH #=> ",bar,hee,hoo"...

絞り込み条件を変える

Kernel$$PREMATCH -> String | nil (6201.0)

$` の別名

...$` の別名

require "English"

str = 'hoge,foo,bar,hee,hoo'

/foo/ =~ str
p $PREMATCH #=> "hoge,"...
<< < 1 2 3 4 5 ... > >>