るりまサーチ

最速Rubyリファレンスマニュアル検索!
742件ヒット [1-100件を表示] (0.043秒)
トップページ > クエリ:@[x] > クエリ:regexp[x] > 種類:インスタンスメソッド[x]

別のキーワード

  1. uri regexp
  2. _builtin regexp
  3. etc sc_regexp
  4. regexp match
  5. regexp last_match

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

...# => ["oo"]
//}

@
param str 文字列を指定します。str との正規表現マッチを行います。

@
param pos 整数を指定します。マッチの開始位置を pos から行うよう制御できます(pos のデフォルト値は 0)。

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

if...
...に失敗した場合、
nil.captures を呼び出そうとして例外 NoMethodError が発生して
しまいます。

//emlist[例][ruby]{
foo, bar, baz = /(foo)(bar)(baz)/.match("foobar").captures

# => -:1: undefined method `captures' for nil:NilClass (NoMethodError)
//}

@
see Regexp#match?...

Regexp#match(str, pos = 0) {|m| ... } -> object | nil (9031.0)

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

...# => ["oo"]
//}

@
param str 文字列を指定します。str との正規表現マッチを行います。

@
param pos 整数を指定します。マッチの開始位置を pos から行うよう制御できます(pos のデフォルト値は 0)。

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

if...
...に失敗した場合、
nil.captures を呼び出そうとして例外 NoMethodError が発生して
しまいます。

//emlist[例][ruby]{
foo, bar, baz = /(foo)(bar)(baz)/.match("foobar").captures

# => -:1: undefined method `captures' for nil:NilClass (NoMethodError)
//}

@
see Regexp#match?...

Regexp#inspect -> String (9029.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#=~(string) -> Integer | nil (9025.0)

文字列 string との正規表現マッチを行います。マッチした場合、 マッチした位置のインデックスを返します(先頭は0)。マッチしなかった 場合、あるいは string が nil の場合には nil を返 します。

...# => nil
//}

組み込み変数 $~ もしくは Regexp.last_match にマッチに関する情報 MatchData が設定されます。

文字列のかわりにSymbolをマッチさせることができます。

@
param string マッチ対象文字列

@
raise TypeError string が nil でも String オ...
...# => 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 "! %s\t%s\n", $!, $@ # => ! can't...

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

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

...# => ["oo"]
//}

@
param str 文字列を指定します。str との正規表現マッチを行います。

@
param pos 整数を指定します。マッチの開始位置を pos から行うよう制御できます(pos のデフォルト値は 0)。

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

if...

絞り込み条件を変える

Regexp#match(str, pos = 0) {|m| ... } -> object | nil (9019.0)

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

...# => ["oo"]
//}

@
param str 文字列を指定します。str との正規表現マッチを行います。

@
param pos 整数を指定します。マッチの開始位置を pos から行うよう制御できます(pos のデフォルト値は 0)。

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

if...

Regexp#==(other) -> bool (9013.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$/)...

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

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

...

@
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 En...

Regexp#encoding -> Encoding (9013.0)

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

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


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

Regexp#eql?(other) -> bool (9013.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$/)...

絞り込み条件を変える

Regexp#match?(str, pos = 0) -> bool (9013.0)

指定された文字列 str に対して 位置 pos から自身が表す正規表現によるマッチングを行います。 マッチした場合 true を返し、マッチしない場合には false を返します。 また、$~ などパターンマッチに関する組み込み変数の値は変更されません。

...ます。
また、$~ などパターンマッチに関する組み込み変数の値は変更されません。

//emlist[例][ruby]{
/R.../.match?("Ruby") # => true
/R.../.match?("Ruby", 1) # => false
/P.../.match?("Ruby") # => false
$& # => nil
//}

@
see Regexp#match...
<< 1 2 3 ... > >>