るりまサーチ

最速Rubyリファレンスマニュアル検索!
338件ヒット [1-100件を表示] (0.273秒)
トップページ > クエリ:_builtin[x] > ライブラリ:ビルトイン[x] > クエリ:E[x] > クラス:Regexp[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

キーワード

検索結果

<< 1 2 3 ... > >>

Regexp#encoding -> Encoding (14203.0)

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

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


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

Regexp#fixed_encoding? -> bool (14127.0)

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

...se を返します。

//emlist[例][ruby]{
# -*- coding:utf-8 -*-

r = /a/
r.fixed_encoding? # => false
r.encoding # => #<Encoding:US-ASCII>
r =~ "\u{6666} a" # => 2
r =~ "\xa1\xa2 a".force_encoding("eu...
...ce_encoding("euc-jp") # => 0

r = /a/u
r.fixed_encoding? # => true
r.encoding # => #<Encoding:UTF-8>
r =~ "\u{6666} a" # => 2
begin
r =~ "\xa1\xa2".force_encoding("euc-jp")
rescue => e
e
....
...# => Encoding::CompatibilityError
e
nd
r =~ "abc".force_encoding("euc-jp") # => 0

r = /\u{6666}/
r.fixed_encoding? # => true
r.encoding # => #<Encoding:UTF-8>
r =~ "\u{6666} a" # => 0
begin...

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

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

...erが同じパターン、オプション、文字コードの正規表現であったら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#casefold? -> bool (14103.0)

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

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

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

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

Regexp#inspect -> String (14103.0)

Regexp#to_s より自然な文字列を返します。

...Regexp#to_s より自然な文字列を返します。

//emlist[例][ruby]{
p /^ugou.*?/i.to_s # => "(?i-mx:^ugou.*?)"
p /^ugou.*?/i.inspect # => "/^ugou.*?/i"
//}

@see Regexp#to_s...

絞り込み条件を変える

Regexp#named_captures -> { String => [Integer] } (14103.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
# => {}
//}...

Regexp#names -> [String] (14103.0)

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

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

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

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

/(.)(.)/.names
# => []
//}...

Regexp#source -> String (14103.0)

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

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

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

Regexp.compile(string, option = nil, code = nil) -> Regexp (14103.0)

文字列 string をコンパイルして正規表現オブジェクトを生成して返します。

...am option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp
::EXTENDED
の論理和を指定します。
Integer 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp
::IGNORECASE の指...
...am code "n", "N" が与えられた時には、生成された正規表現のエンコーディングは ASCII-8BIT になります。
それ以外の指定は警告を出力します。

@raise RegexpError 正規表現のコンパイルに失敗した場合発生します。

//emlist[...
...This is Regexp"
t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1.match(str)
p $~ # => "This is Regexp"

t2 = Regexp.compile('
this # ここは使用されない
\ is
\ regexp # ここも使用されない
', Regexp::EXTENDED | Regexp::IGNORECASE)
t2.match(str)
p Regexp.last_m...

Regexp.escape(string) -> String (14103.0)

string の中で正規表現において特別な意味を持つ文字の直前にエ スケープ文字(バックスラッシュ)を挿入した文字列を返します。

...持つ文字の直前にエ
スケープ文字(バックスラッシュ)を挿入した文字列を返します。

@param string 正規表現において特別な意味をもつ文字をもつ文字列を指定します。

//emlist[例][ruby]{
rp = Regexp.escape("$bc^")
p rp # => "\\$bc\\^"
//}...

絞り込み条件を変える

<< 1 2 3 ... > >>