68件ヒット
[1-68件を表示]
(0.068秒)
種類
- 特異メソッド (22)
- インスタンスメソッド (13)
- 変数 (11)
- 文書 (11)
- クラス (11)
モジュール
- Kernel (11)
キーワード
- StringScanner (11)
- byterindex (2)
- compile (11)
- new (11)
-
ruby 1
. 6 feature (11) -
to
_ s (11)
検索結果
先頭5件
-
Kernel
$ $ ~ -> MatchData | nil (18201.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 (5316.0) -
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) -> stable-snapshot
: 2003-01-22: errno
EAGAIN と 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) [i586-linux]......2, 0.1) {|f| p f }
=> -:1:in `step': step cannot be 0 (ArgumentError)
from -: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 を代入でき... -
String
# byterindex(pattern , offset = self . bytesize) -> Integer | nil (166.0) -
文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...していってここで見つかる
//}
//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterindex("ing", -1) # => 9
# ing # インデックス -1 の文字から探索を始める
# ing
# ing # 左にずらしていってここで見つか......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......erindex('o', 0) # => nil
'foo'.byterindex('o', 1) # => 1
'foo'.byterindex('o', 2) # => 2
'foo'.byterindex('o', 3) # => 2
'foo'.byterindex('o', -1) # => 2
'foo'.byterindex('o', -2) # => 1
'foo'.byterindex('o', -3) # => nil
'foo'.byterindex('o', -4) # => nil
//}
@see String#rindex, String#byteindex... -
Regexp
. compile(string , option = nil , code = nil) -> Regexp (112.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...指定と同じになります。
@param code "n", "N" が与えられた時には、生成された正規表現のエンコーディングは ASCII-8BIT になります。
それ以外の指定は警告を出力します。
@raise RegexpError 正規表現のコンパイルに失敗... -
Regexp
. new(string , option = nil , code = nil) -> Regexp (112.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...指定と同じになります。
@param code "n", "N" が与えられた時には、生成された正規表現のエンコーディングは ASCII-8BIT になります。
それ以外の指定は警告を出力します。
@raise RegexpError 正規表現のコンパイルに失敗... -
MatchData
# to _ s -> String (106.0) -
マッチした文字列全体を返します。
...マッチした文字列全体を返します。
//emlist[例][ruby]{
/bar/ =~ "foobarbaz"
p $~ # => #<MatchData:0x401b1be4>
p $~.to_s # => "bar"
//}... -
StringScanner (24.0)
-
StringScanner は文字列スキャナクラスです。 簡単に高速なスキャナを記述できます。
...[ruby]{
# 次の行以降の内容を EUC-JP として保存して試してください
# vim:set fileencoding=euc-jp:
require 'strscan'
s = StringScanner.new("るびい") # 文字コードはEUC-JPとします
p s.exist?(/び/) #=> 4
//}
StringScanner は $~ $& $1 $2 …… などの正規表現...