ライブラリ
- English (55)
- ビルトイン (614)
- readline (11)
-
rubygems
/ dependency (11) -
rubygems
/ platform (11) -
rubygems
/ requirement (11) - set (22)
- syslog (55)
- uri (22)
- win32ole (11)
クラス
- Array (56)
- BasicObject (11)
-
Gem
:: Dependency (11) -
Gem
:: Platform (11) -
Gem
:: Requirement (11) - MatchData (169)
- NilClass (6)
- Object (20)
- Regexp (55)
- Set (22)
- String (22)
- Symbol (11)
-
WIN32OLE
_ TYPE (11)
モジュール
- Enumerable (22)
- Kernel (275)
- Readline (11)
- Syslog (44)
- URI (22)
キーワード
-
$ & (11) -
$ & # 39; (11) -
$ 1 (11) -
$ 10 (11) -
$ 11 (11) -
$ 2 (11) -
$ 3 (11) -
$ 4 (11) -
$ 5 (11) -
$ 6 (11) -
$ 7 (11) -
$ 8 (11) -
$ 9 (11) -
$ LAST _ MATCH _ INFO (11) -
$ LAST _ PAREN _ MATCH (11) -
$ MATCH (11) -
$ POSTMATCH (11) -
$ PREMATCH (11) -
$ ` (11) -
$ ~ (11) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - Lazy (11)
- Regexp (11)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (11)
- Syslog (11)
- [] (44)
- begin (11)
- byteoffset (4)
- caller (33)
- captures (11)
- chunk (11)
- count (11)
-
delete
_ if (11) - end (11)
- filter! (12)
-
fixed
_ encoding? (11) -
keep
_ if (22) -
last
_ match (22) - length (11)
- logger (11)
- loop (22)
- mask (11)
- mask= (11)
-
method
_ missing (11) - offset (22)
- open! (11)
-
post
_ match (11) -
pre
_ match (11) - progids (11)
- readline (11)
- regexp (22)
- reject! (11)
- reopen (11)
-
respond
_ to _ missing? (11) -
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 2 feature (11) -
ruby 1
. 8 . 3 feature (11) -
ruby 1
. 8 . 4 feature (11) - select! (22)
- shell (6)
- size (11)
-
slice
_ when (11) -
to
_ a (11) -
to
_ s (11) - tracer (11)
- ~ (11)
- クラス/メソッドの定義 (11)
- 制御構造 (11)
- 正規表現 (11)
- 演算子式 (11)
検索結果
先頭5件
-
Regexp
# =~(string) -> Integer | nil (18142.0) -
文字列 string との正規表現マッチを行います。マッチした場合、 マッチした位置のインデックスを返します(先頭は0)。マッチしなかった 場合、あるいは string が nil の場合には nil を返 します。
...しなかった
場合、あるいは string が nil の場合には nil を返
します。
//emlist[例][ruby]{
p /foo/ =~ "foo" # => 0
p /foo/ =~ "afoo" # => 1
p /foo/ =~ "bar" # => nil
//}
組み込み変数 $~ もしくは Regexp.last_match にマッチに関する情報 MatchData が設定....../emlist[例][ruby]{
p /foo/ =~ "foo" # => 0
p Regexp.last_match(0) # => "foo"
p /foo/ =~ "afoo" # => 1
p $~[0] # => "foo"
p /foo/ =~ "bar" # => nil
unless /foo/ === "bar"
puts "not match " # => not match
end
str = []
begin
/ugo/ =~ str
rescue TypeError
pr... -
String
# =~(other) -> Integer | nil (18130.0) -
正規表現 other とのマッチを行います。 マッチが成功すればマッチした位置のインデックスを、そうでなければ nil を返します。
...表現でも文字列でもない場合は
other =~ self を行います。
このメソッドが実行されると、組み込み変数 $~, $1, ...
にマッチに関する情報が設定されます。
@param other 正規表現もしくは =~ メソッドを持つオブジェクト
@raise......TypeError other が文字列の場合に発生します。
//emlist[例][ruby]{
p "string" =~ /str/ # => 0
p "string" =~ /not/ # => nil
p "abcfoo" =~ /foo/ # => 3
//}... -
NilClass
# =~(other) -> nil (18128.0) -
右辺に正規表現オブジェクトを置いた正規表現マッチ obj =~ /RE/ をサポートするためのメソッドです。常に nil を返します。
...現マッチ obj =~ /RE/
をサポートするためのメソッドです。常に nil を返します。
@param other 任意のオブジェクトです。結果に影響しません。
//emlist[例][ruby]{
obj = 'regexp'
p(obj =~ /re/) #=> 0
obj = nil
p(obj =~ /re/) #=> nil
//}
@see String#=~... -
Object
# =~(other) -> nil (18128.0) -
右辺に正規表現オブジェクトを置いた正規表現マッチ obj =~ /RE/ をサポートするためのメソッドです。常に nil を返します。
...表現オブジェクトを置いた正規表現マッチ obj =~ /RE/
をサポートするためのメソッドです。常に nil を返します。
このメソッドは Ruby 2.6 から deprecated です。
この定義により、=~ が再定義されたオブジェクトでは正常にマッ......チを行い、
それ以外のものは nil を返すようになります。
@param other 任意のオブジェクトです。結果に影響しません。
//emlist[例][ruby]{
obj = 'regexp'
p(obj =~ /re/) #=> 0
obj = nil
p(obj =~ /re/) #=> nil
//}
@see String#=~......ッチ obj =~ /RE/
をサポートするためのメソッドです。常に nil を返します。
このメソッドは Ruby 2.6 から deprecated です。
意図せずに Array などに対して呼ばれた時にバグの原因になっていたため、
代わりに NilClass#=~ が定義さ......れています。
@param other 任意のオブジェクトです。結果に影響しません。
//emlist[例][ruby]{
obj = 'regexp'
p(obj =~ /re/) #=> 0
obj = nil
p(obj =~ /re/) #=> nil
//}
@see String#=~... -
Symbol
# =~(other) -> Integer | nil (18124.0) -
正規表現 other とのマッチを行います。
....to_s =~ other と同じです。)
@param other 比較対象のシンボルを指定します。
@return マッチが成功すればマッチした位置のインデックスを、そうでなければ nil を返します。
p :foo =~ /foo/ # => 0
p :foobar =~ /bar/ # => 3
p :foo =~ /bar....../ # => nil
@see String#=~... -
Gem
:: Dependency # =~(other) -> bool (18100.0) -
self と other を比較して真偽値を返します。
self と other を比較して真偽値を返します。
self の Gem::Dependency#name が正規表現として other とマッチしない場合は偽を返します。
self が other との依存関係を満たしていれば真を返します。満たしていなければ偽を返します。 -
Gem
:: Platform # =~(other) -> bool (18100.0) -
自身と other のプラットフォームが一致する場合に真を返します。 そうでない場合は、偽を返します。
自身と other のプラットフォームが一致する場合に真を返します。
そうでない場合は、偽を返します。
other が文字列の場合は、まず Gem::Platform に変換してから比較を行います。
other が文字列でも Gem::Platform でもない場合は nil を返します。
@param other 比較対象のオブジェクトです。
@see Gem::Platform#=== -
Gem
:: Requirement # =~(version) -> bool (15100.0) -
引数 version が自身に含まれる全ての必要条件を満たす場合に true を返します。 そうでなければ、false を返します。
引数 version が自身に含まれる全ての必要条件を満たす場合に true を返します。
そうでなければ、false を返します。
@param version Gem::Version のインスタンスを指定します。
//emlist[][ruby]{
req = Gem::Requirement.new("~> 3.2.1")
p req.satisfied_by?(Gem::Version.new('3.2.9')) # => true
p req.satisfied_by?(Gem::Version.new('3.3.0')) # => false
//} -
ruby 1
. 6 feature (120.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...正しく埋め込めるようにするためです。
((<ruby-bugs-ja:PR#231>))
p Regexp.quote("#")
p /a#{Regexp.quote("#")}b/x =~ "ab"
=> -:3: warning: ambiguous first argument; make sure
ruby 1.6.7 (2002-03-01) [i586-linux]
"#"
0......うになりました。
: 2002-04-26: Regexp.quote
((<ruby-bugs-ja:PR#231>))
p Regexp.quote("\t")
p /a#{Regexp.quote("\t")}b/x =~ "ab"
=> -:3: warning: ambiguous first argument; make sure
ruby 1.6.7 (2002-03-01) [i586-linux]
"\t"
0......1.9
: 2002-04-01: ((<組み込み変数/$~>))
$~ に nil を代入できないバグが修正されました。((<ruby-dev:16697>))
/foo/ =~ "foo"
p $~
$~ = nil
p $~
=> ruby 1.6.7 (2002-03-01) [i586-linux]
#<MatchData:0x401b1be4>
-:3: wrong argument type nil... -
Regexp
# fixed _ encoding? -> bool (54.0) -
正規表現が任意の ASCII 互換エンコーディングとマッチ可能な時に false を返します。
...# => false
r.encoding # => #<Encoding:US-ASCII>
r =~ "\u{6666} a" # => 2
r =~ "\xa1\xa2 a".force_encoding("euc-jp") # => 2
r =~ "abc".force_encoding("euc-jp") # => 0
r = /a/u
r.fixed_encoding?......# => #<Encoding:UTF-8>
r =~ "\u{6666} a" # => 2
begin
r =~ "\xa1\xa2".force_encoding("euc-jp")
rescue => e
e.class # => Encoding::CompatibilityError
end
r =~ "abc".force_encoding("euc-jp") # =......# => #<Encoding:UTF-8>
r =~ "\u{6666} a" # => 0
begin
r =~ "\xa1\xa2".force_encoding("euc-jp")
rescue => e
e.class # => Encoding::CompatibilityError
end
r =~ "abc".force_encoding("euc-jp") # =...