るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

キーワード

検索結果

Kernel$$~ -> MatchData | nil (18113.0)

現在のスコープで最後に成功したマッチに関する MatchDataオブジェクトです。 Regexp.last_match の別名です。

...atchDataオブジェクトです。
Regexp.last_match の別名です。

このデータから n 番目のマッチ ($n) を取り出すためには $~[n] を使います。

この値に代入すると Regexp.last_match や、 $&, $1, $2, ... などの関連する組み込み変数の値が変化...
...ます。

この変数はローカルスコープかつスレッドローカルです。
Ruby
起動時の初期値は nil です。

//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
p $~[1]
end
#=> "http://example.com"
//}...

ruby 1.6 feature (5203.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...ruby 1.6 feature
ruby
version 1.6 は安定版です。この版での変更はバグ修正がメイン
になります。

((<stable-snapshot|URL:ftp://ftp.netlab.co.jp/pub/lang/ruby/stable-snapshot.tar.gz>)) は、日々更新される安定版の最新ソースです。

== 1.6.8 (2002-12-24) ->...
...EWOULDBLOCK

=> ruby 1.6.7 (2002-03-01) [i586-linux]
Errno::EAGAIN
Errno::EWOULDBLOCK

=> ruby 1.6.8 (2002-12-24) [i586-linux]
Errno::EAGAIN
-:2: uninitialized constant EWOULDBLOCK at Errno (NameError)

=> ruby 1.6.8 (2003-02-13) [i...
...1
ruby
1.6.7 (2002-03-01) [i586-linux]

=> ruby 1.6.7 (2002-04-10) [i586-linux]
1
1.1
:
1.9

: 2002-04-01: ((<組み込み変数/$~>))

$~
に nil を代入できないバグが修正されました。((<ruby-dev:16697>))

/foo/ =~ "foo"
p $~
$~
...

String#byterindex(pattern, offset = self.bytesize) -> Integer | nil (36.0)

文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。

...mlist[String#byteindex の場合][ruby]{
p "stringstring".byteindex("ing", 1) # => 3
# ing # ここから探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}

//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterindex("in...
...pattern 探索する部分文字列または正規表現
@param offset 探索を始めるバイト単位のインデックス

//emlist[例][ruby]{
'foo'.byterindex('f') # => 0
'foo'.byterindex('o') # => 2
'foo'.byterindex('oo') # => 1
'foo'.byterindex('ooo') # => nil

'foo'.byterindex(/f/) #...
...ex(/o+/) # => 2
$~
#=> #<MatchData "o">

# 最長にするには否定戻り読み(negative look-behind)と組み合わせる
'foo'.byterindex(/(?<!o)o+/) # => 1
$~
#=> #<MatchData "oo">

# またはbyteindexを否定先読み(negative look-ahead)
'foo'.byteindex(/o+(?!.*o)/) # => 1
$~
#=> #<MatchDa...

StringScanner (30.0)

StringScanner は文字列スキャナクラスです。 簡単に高速なスキャナを記述できます。

...StringScanner は文字列スキャナクラスです。
簡単に高速なスキャナを記述できます。

//emlist[例][ruby]{
require 'strscan'

s = StringScanner.new('This is an example string')
s.eos? #=> false

p s.scan(/\w+/) #=> "This"
p s.scan(/\w+/) #=> nil
p s.scan(/\s...
...先頭にあり、
その地点でのみマッチを試します。マッチしたらその後ろにポインタを進めます。

//emlist[例][ruby]{
require 'strscan'

## a string and a scan pointer ("_" = scan pointer)

s = StringScanner.new('This is an example string')
# _This is an example...
...

//emlist[例:][ruby]{
# 次の行以降の内容を EUC-JP として保存して試してください
# vim:set fileencoding=euc-jp:
require 'strscan'
s = StringScanner.new("るびい") # 文字コードはEUC-JPとします
p s.exist?(/び/) #=> 4
//}

StringScanner は $~ $& $1 $2 …… な...

MatchData#to_s -> String (12.0)

マッチした文字列全体を返します。

...マッチした文字列全体を返します。

//emlist[例][ruby]{
/bar/ =~ "foobarbaz"
p $~ # => #<MatchData:0x401b1be4>
p $~.to_s # => "bar"
//}...

絞り込み条件を変える

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

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

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

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

t2 = Regexp.compile('
this # ここは使用されない
\ is
\ r...

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

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

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

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

t2 = Regexp.compile('
this # ここは使用されない
\ is
\ r...

Regexp.new(string, option = nil) -> Regexp (12.0)

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

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

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

t2 = Regexp.compile('
this # ここは使用されない
\ is
\ r...

Regexp.new(string, option = nil, code = nil) -> Regexp (12.0)

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

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

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

t2 = Regexp.compile('
this # ここは使用されない
\ is
\ r...