68件ヒット
[1-68件を表示]
(0.118秒)
種類
- 特異メソッド (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 (21207.0) -
現在のスコープで最後に成功したマッチに関する MatchDataオブジェクトです。 Regexp.last_match の別名です。
...したマッチに関する MatchDataオブジェクトです。
Regexp.last_match の別名です。
このデータから n 番目のマッチ ($n) を取り出すためには $~[n] を使います。
この値に代入すると Regexp.last_match や、 $&, $1, $2, ... などの関連する組......と TypeError が発生します。
この変数はローカルスコープかつスレッドローカルです。
Ruby起動時の初期値は nil です。
//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
p $~[1]
end
#=> "... -
String
# byterindex(pattern , offset = self . bytesize) -> Integer | nil (9266.0) -
文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...ンデックス offset から左に向かって pattern を探索します。
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。
引数 pattern は探索する部分文字列または正規表現......String#byteindex の場合][ruby]{
p "stringstring".byteindex("ing", 1) # => 3
# ing # ここから探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}
//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterindex("ing", -1......terindex('f') # => 0
'foo'.byterindex('o') # => 2
'foo'.byterindex('oo') # => 1
'foo'.byterindex('ooo') # => nil
'foo'.byterindex(/f/) # => 0
'foo'.byterindex(/o/) # => 2
'foo'.byterindex(/oo/) # => 1
'foo'.byterindex(/ooo/) # => nil
# 右でのマッチが優先
'foo'.byterindex(/o+/) # => 2
$~ #... -
ruby 1
. 6 feature (8352.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) ->......stable-snapshot
: 2003-01-22: errno
EAGAIN と EWOULDBLOCK が同じ値のシステムで、EWOULDBLOCK がなくなっ
ていました。現在は、このようなシステムでは、EWOULDBLOCK は、EAGAIN
として定義されています。(これは 1.6.7 とは異なる挙......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 を代入でき... -
StringScanner (6024.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......ntil(/string/) #=> " string"
p s.scan_until(/\s+/) #=> nil
p s.scan_until(/string/) #=> nil
end
p "case1"
case1
p "case2"
case2
//}
スキャンポインタの位置は文字単位でなくバイト単位となります。
//emlist[例:][ruby]{
# 次の行以降の内容を EUC-JP と......fileencoding=euc-jp:
require 'strscan'
s = StringScanner.new("るびい") # 文字コードはEUC-JPとします
p s.exist?(/び/) #=> 4
//}
StringScanner は $~ $& $1 $2 …… などの正規表現関連変数を
セットしません。代わりに StringScanner#[] , StringScanner#matched? な... -
Regexp
. compile(string , option = nil , code = nil) -> Regexp (3212.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...tring をコンパイルして正規表現オブジェクトを生成して返します。
第一引数が正規表現であれば第一引数を複製して返します。第二、第三引数は警告の上無視されます。
@param string 正規表現を文字列として与えます。
@par......er 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp::IGNORECASE の指定と同じになります。
@param code "n", "N" が与えられた時には、生成された正規表現のエンコーディングは ASCII-8......警告を出力します。
@raise 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 #... -
Regexp
. new(string , option = nil , code = nil) -> Regexp (3212.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...tring をコンパイルして正規表現オブジェクトを生成して返します。
第一引数が正規表現であれば第一引数を複製して返します。第二、第三引数は警告の上無視されます。
@param string 正規表現を文字列として与えます。
@par......er 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp::IGNORECASE の指定と同じになります。
@param code "n", "N" が与えられた時には、生成された正規表現のエンコーディングは ASCII-8......警告を出力します。
@raise 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 #... -
MatchData
# to _ s -> String (206.0) -
マッチした文字列全体を返します。
...マッチした文字列全体を返します。
//emlist[例][ruby]{
/bar/ =~ "foobarbaz"
p $~ # => #<MatchData:0x401b1be4>
p $~.to_s # => "bar"
//}...