934件ヒット
[101-200件を表示]
(0.177秒)
ライブラリ
- ビルトイン (715)
- abbrev (12)
-
json
/ add / regexp (12) -
minitest
/ spec (2) -
minitest
/ unit (1) - optparse (12)
-
rdoc
/ parser (12) - scanf (12)
- strscan (120)
クラス
- Array (12)
- MatchData (24)
- Module (1)
- NilClass (7)
- Object (46)
- OptionParser (12)
-
RDoc
:: Options (36) -
RDoc
:: Parser (12) - Regexp (189)
- String (345)
- StringScanner (120)
- Symbol (129)
モジュール
キーワード
- !~ (12)
- == (12)
- === (24)
- =~ (28)
- [] (132)
- []= (84)
- abbrev (12)
- accept (12)
-
assert
_ match (1) - check (12)
-
check
_ until (12) - eql? (12)
- exclude (12)
- exclude= (12)
- exist? (12)
-
extra
_ accessors (12) - hash (12)
-
infect
_ with _ assertions (1) - inspect (12)
- match (48)
- match? (39)
-
must
_ match (1) -
named
_ captures (12) - names (24)
-
parse
_ files _ matching (12) - scan (12)
-
scan
_ full (12) -
scan
_ until (12) - scanf (12)
-
search
_ full (12) - skip (12)
-
skip
_ until (12) - slice (132)
- slice! (72)
- source (12)
-
to
_ json (12) -
to
_ regexp (12) -
to
_ s (12) - ~ (12)
検索結果
先頭5件
-
Regexp
# named _ captures -> { String => [Integer] } (15101.0) -
正規表現に含まれる名前付きキャプチャ(named capture)の情報を Hash で返します。
...ャプチャ(named capture)の情報を
Hash で返します。
Hash のキーは名前付きキャプチャの名前で、値は
その名前に関連付けられたキャプチャの index のリストを返します。
//emlist[例][ruby]{
/(?<foo>.)(?<bar>.)/.named_captures
# => {"foo"=>[1], "......bar"=>[2]}
/(?<foo>.)(?<foo>.)/.named_captures
# => {"foo"=>[1, 2]}
# 名前付きキャプチャを持たないときは空の Hash を返します。
/(.)(.)/.named_captures
# => {}
//}... -
Object
# to _ regexp -> Regexp (12331.0) -
オブジェクトの Regexp への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
...オブジェクトの Regexp への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。
説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必......ての場面で代置可能であるような、
* 正規表現そのものとみなせるようなもの
という厳しいものになっています。
//emlist[][ruby]{
class Foo
def to_regexp
/[\d]+/
end
end
it = Foo.new
p Regexp.union(/^at/, it) #=> /(?-mix:^at)|(?-mix:[\d]+)/
//}... -
Regexp
# =~(string) -> Integer | nil (9125.0) -
文字列 string との正規表現マッチを行います。マッチした場合、 マッチした位置のインデックスを返します(先頭は0)。マッチしなかった 場合、あるいは string が nil の場合には nil を返 します。
...文字列 string との正規表現マッチを行います。マッチした場合、
マッチした位置のインデックスを返します(先頭は0)。マッチしなかった
場合、あるいは string が nil の場合には nil を返
します。
//emlist[例][ruby]{
p /foo/ =~ "foo"......込み変数 $~ もしくは Regexp.last_match にマッチに関する情報 MatchData が設定されます。
文字列のかわりにSymbolをマッチさせることができます。
@param string マッチ対象文字列
@raise TypeError string が nil でも String オブジェクト......ist[例][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
printf... -
Regexp
# ==(other) -> bool (9107.0) -
otherが同じパターン、オプション、文字コードの正規表現であったらtrueを返します。
...otherが同じパターン、オプション、文字コードの正規表現であったらtrueを返します。
@param other 正規表現を指定します。
//emlist[例][ruby]{
p /^eee$/ == /~eee$/x # => false
p /^eee$/ == /~eee$/i # => false
p /^eee$/e == /~eee$/u # => false
p /^......eee$/ == Regexp.new("^eee$") # => true
p /^eee$/.eql?(/^eee$/) # => true
//}... -
Regexp
# eql?(other) -> bool (9107.0) -
otherが同じパターン、オプション、文字コードの正規表現であったらtrueを返します。
...otherが同じパターン、オプション、文字コードの正規表現であったらtrueを返します。
@param other 正規表現を指定します。
//emlist[例][ruby]{
p /^eee$/ == /~eee$/x # => false
p /^eee$/ == /~eee$/i # => false
p /^eee$/e == /~eee$/u # => false
p /^......eee$/ == Regexp.new("^eee$") # => true
p /^eee$/.eql?(/^eee$/) # => true
//}... -
Regexp
# ~ -> Integer | nil (9107.0) -
変数 $_ の値との間でのマッチをとります。
...mlist[][ruby]{
self =~ $_
//}
//emlist[例][ruby]{
$_ = "hogehoge"
if /foo/
puts "match"
else
puts "no match"
end
# => no match
# ただし、警告がでる。warning: regex literal in condition
reg = Regexp.compile("foo")
if ~ reg
puts "match"
else
puts "no match"
end
# => no match......if reg
puts "match"
else
puts "no match"
end
# => match
# reg は nil でも false でも無いので常にtrue
//}... -
Regexp
# ===(string) -> bool (9101.0) -
文字列 string との正規表現マッチを行います。 マッチした場合は真を返します。
...文字列 string との正規表現マッチを行います。
マッチした場合は真を返します。
string が文字列でもシンボルでもない場合には false を返します。
このメソッドは主にcase文での比較に用いられます。
@param string マッチ対象......文字列
//emlist[例][ruby]{
a = "HELLO"
case a
when /\A[a-z]*\z/; puts "Lower case"
when /\A[A-Z]*\z/; puts "Upper case"
else; puts "Mixed case"
end
# => Upper case
/\A[a-z]*\z/ === "HELLO" # => false
/\A[A-Z]*\z/ === "HELLO" # => true
//}
@see Enumerable#grep, Object#===... -
Regexp
# hash -> Integer (9101.0) -
正規表現のオプションやテキストに基づいたハッシュ値を返します。
...正規表現のオプションやテキストに基づいたハッシュ値を返します。
//emlist[例][ruby]{
p /abc/i.hash # => 4893115
p /abc/.hash # => 4856055
//}... -
Regexp
# names -> [String] (9101.0) -
正規表現に含まれる名前付きキャプチャ(named capture)の名前を 文字列の配列で返します。
...正規表現に含まれる名前付きキャプチャ(named capture)の名前を
文字列の配列で返します。
//emlist[例][ruby]{
/(?<foo>.)(?<bar>.)(?<baz>.)/.names
# => ["foo", "bar", "baz"]
/(?<foo>.)(?<foo>.)/.names
# => ["foo"]
/(.)(.)/.names
# => []
//}...