るりまサーチ

最速Rubyリファレンスマニュアル検索!
1007件ヒット [1-100件を表示] (0.173秒)

別のキーワード

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

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

MatchData#regexp -> Regexp (32410.0)

自身の元になった正規表現オブジェクトを返します。

...自身の元になった正規表現オブジェクトを返します。

//emlist[例][ruby]{
m = /a.*b/.match("abc")
m.regexp # => /a.*b/
//}...

Regexp.compile(string, option = nil, code = nil) -> Regexp (23306.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.new(string, option = nil, code = nil) -> Regexp (23306.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.try_convert(obj) -> Regexp | nil (23247.0)

obj を to_regexp メソッドで Regexp オブジェクトに変換しようと 試みます。

...obj を to_regexp メソッドで Regexp オブジェクトに変換しようと
試みます。

変換に成功した場合はそれを返し、失敗時には nil を返します。

//emlist[例][ruby]{
Regexp
.try_convert(/re/) # => /re/
Regexp
.try_convert("re") # => nil
//}...

Regexp#encoding -> Encoding (23208.0)

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

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


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

絞り込み条件を変える

Regexp#fixed_encoding? -> bool (23126.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#inspect -> String (23124.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#casefold? -> bool (23120.0)

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

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

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

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

Regexp#eql?(other) -> bool (23114.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.escape(string) -> String (23108.0)

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

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

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

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

絞り込み条件を変える

<< 1 2 3 ... > >>