るりまサーチ

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

別のキーワード

  1. bigdecimal/util to_d
  2. float to_d
  3. rsa d=
  4. kernel $-d
  5. rsa d

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

MatchData#regexp -> Regexp (21209.0)

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

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

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

Regexp#encoding -> Encoding (15213.0)

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

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


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

Regexp#casefold? -> bool (15119.0)

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

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

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

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

Regexp#fixed_encoding? -> bool (15101.0)

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

...-*- 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("euc-jp") # => 2
r =~ "abc".force_encoding("...
...xed_encoding? # => true
r.encoding # => #<Encoding:UTF-8>
r =~ "\u{6666} a" # => 2
begin
r =~ "\xa1\xa2".force_encoding("euc-jp")
rescue => e
e.class # => Encodi...
...r
end
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
r =~ "\xa1\xa2".force_encoding(...

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
# => {}
//}...

絞り込み条件を変える

Regexp#match(str, pos = 0) -> MatchData | nil (9113.0)

指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。

...列 str に対して位置 pos から自身が表す正規表現によるマッ
チングを行います。マッチした場合には結果を MatchData オブジェクトで返し
ます。
マッチしなかった場合 nil を返します。

省略可能な第二引数 pos を指定すると、...
...pos を指定しても MatchData#offset 等の結果
には影響しません。つまり、
//emlist[][ruby]{
re.match(str[pos..-1])
//}

//emlist[][ruby]{
re.match(str, pos)
//}
は異なります。


ブロックを渡すと、マッチした場合に限り MatchData オブジェクトがブ...
...ら行うよう制御できます(pos のデフォルト値は 0)。

//emlist[例][ruby]{
reg = Regexp.new("foo")

if reg.match("foobar")
puts "match"
end
# => match

p reg.match("foobar") # => #<MatchData:0x29403fc>
p reg.match("bar") # => nil

p /(foo)(bar)(baz)/.match("foobarbaz").to_a.valu...

Regexp#to_json(*args) -> String (9043.0)

自身を JSON 形式の文字列に変換して返します。

...enerator::GeneratorMethods::Hash#to_json を呼び出しています。

@param args 引数には何の意味もありません。

//emlist[例][ruby]{
require "json/add/core"

/0\d{1,4}-\d{1,4}-\d{4}/.to_json # => "{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"0\\\\d{1,4}-\\\\d{1,4}-\\\\d{4}\"}"
//}...
...ds::Hash#to_json を呼び出しています。

@param args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json
に渡されます。

//emlist[例][ruby]{
require "json/add/core"

/0\d{1,4}-\d{1,4}-\d{4}/.to_json # => "{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"0\\\\d...
...{1,4}-\\\\d{1,4}-\\\\d{4}\"}"
//}...

Object#to_regexp -> Regexp (6243.0)

オブジェクトの Regexp への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

...オブジェクトの Regexp への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。

説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
...
...ての場面で代置可能であるような、
* 正規表現そのものとみなせるようなもの
という厳しいものになっています。

//emlist[][ruby]{
class Foo
d
ef to_regexp
/[\d]+/
end
end

it = Foo.new
p Regexp.union(/^at/, it) #=> /(?-mix:^at)|(?-mix:[\d]+)/
//}...

RDoc::Options#exclude -> Regexp (6218.0)

コマンドライン引数の --exclude オプションで指定した正規表現を返します。 複数指定していた場合は、1 つの Regexp オブジェクトにまとめられた ものを返します。

...コマンドライン引数の --exclude オプションで指定した正規表現を返します。
複数指定していた場合は、1 つの Regexp オブジェクトにまとめられた
ものを返します。...
<< 1 2 3 ... > >>