るりまサーチ

最速Rubyリファレンスマニュアル検索!
225件ヒット [101-200件を表示] (0.150秒)

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dh p
  5. rsa p

ライブラリ

キーワード

検索結果

<< < 1 2 3 > >>

Regexp#eql?(other) -> bool (3032.0)

otherが同じパターン、オプション、文字コードの正規表現であったらtrueを返します。

...あったら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$/) # => tru...

Regexp#to_s -> String (3032.0)

正規表現の文字列表現を生成して返します。返される文字列は他の正規表 現に埋め込んでもその意味が保持されるようになっています。

...
現に埋め込んでもその意味が保持されるようになっています。

//emlist[][ruby]{
re = /foo|bar|baz/i
p
re.to_s # => "(?i-mx:foo|bar|baz)"
p
/#{re}+/o # => /(?i-mx:foo|bar|baz)+/
//}

ただし、後方参照を含む正規表現は意図通りにはならない...
...emlist[][ruby]{
re = /(foo|bar)\1/ # \1 は、foo か bar
p
/(baz)#{re}/ # \1 は、baz

# => /(baz)(?-mix:(foo|bar)\1)/
//}

//emlist[使用例][ruby]{
re = /foo|bar|baz/i
p
re.to_s # => "(?i-mx:foo|bar|baz)"
p
/#{re}+/o # => /(?i-mx:foo|bar|baz)+/
//}

@see Regexp#inspect...

Regexp#casefold? -> bool (3014.0)

正規表現が大文字小文字の判定をしないようにコンパイルされている時、 真を返します。

...正規表現が大文字小文字の判定をしないようにコンパイルされている時、
真を返します。

//emlist[例][ruby]{
reg = Regexp.new("foobar", Regexp::IGNORECASE)
p
reg.casefold? # => true

reg = Regexp.new("hogehoge")
p
reg.casefold? # => false
//}...

Regexp#hash -> Integer (3014.0)

正規表現のオプションやテキストに基づいたハッシュ値を返します。

...正規表現のオプションやテキストに基づいたハッシュ値を返します。

//emlist[例][ruby]{
p
/abc/i.hash # => 4893115
p
/abc/.hash # => 4856055
//}...

Regexp#source -> String (3008.0)

その正規表現のもととなった文字列表現を生成して返します。

...その正規表現のもととなった文字列表現を生成して返します。

//emlist[例][ruby]{
re = /foo|bar|baz/i
p
re.source # => "foo|bar|baz"
//}...

絞り込み条件を変える

Regexp#===(string) -> bool (3002.0)

文字列 string との正規表現マッチを行います。 マッチした場合は真を返します。

...に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#encoding -> Encoding (3002.0)

正規表現オブジェクトのエンコーディングを表す Encoding オブジェクト を返します。

...正規表現オブジェクトのエンコーディングを表す Encoding オブジェクト
を返します。


@see d:spec/regexp#encoding...

Regexp#fixed_encoding? -> bool (3002.0)

正規表現が任意の ASCII 互換エンコーディングとマッチ可能な時に false を返します。

...# => #<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? # => true
r.encoding...
...# => 2
begin
r =~ "\xa1\xa2".force_encoding("euc-jp")
rescue => e
e.class # => Encoding::CompatibilityError
end
r =~ "abc".force_encoding("euc-jp") # => 0

r = /\u{6666}/
r.fixed_encoding?...
...# => #<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") # => nil
//}...

Regexp#names -> [String] (3002.0)

正規表現に含まれる名前付きキャプチャ(named capture)の名前を 文字列の配列で返します。

...正規表現に含まれる名前付きキャプチャ(named capture)の名前を
文字列の配列で返します。

//emlist[例][ruby]{
/(?<foo>.)(?<bar>.)(?<baz>.)/.names

# => ["foo", "bar", "baz"]
/(?<foo>.)(?<foo>.)/.names
# => ["foo"]

/(.)(.)/.names
# => []
//}...
<< < 1 2 3 > >>