モジュール
- Kernel (12)
キーワード
- StringScanner (12)
- byterindex (3)
- compile (12)
- new (12)
-
rb
_ backref _ get (12) -
rb
_ backref _ set (12) -
ruby 1
. 6 feature (12) -
special
_ local _ set (12) -
to
_ s (12)
検索結果
先頭5件
-
Kernel
$ $ ~ -> MatchData | nil (18201.0) -
現在のスコープで最後に成功したマッチに関する MatchDataオブジェクトです。 Regexp.last_match の別名です。
...に成功したマッチに関する MatchDataオブジェクトです。
Regexp.last_match の別名です。
このデータから n 番目のマッチ ($n) を取り出すためには $~[n] を使います。
この値に代入すると Regexp.last_match や、 $&, $1, $2, ... などの関連......す。
MatchData オブジェクトでも nil でもない値を代入しようとすると TypeError が発生します。
この変数はローカルスコープかつスレッドローカルです。
Ruby起動時の初期値は nil です。
//emlist[例][ruby]{
str = '<p><a href="http://examp......le.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
p $~[1]
end
#=> "http://example.com"
//}... -
String
# byterindex(pattern , offset = self . bytesize) -> Integer | nil (6418.0) -
文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...イト単位のインデックス offset から左に向かって pattern を探索します。
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。
引数 pattern は探索する部分文字列ま......たは正規表現で指定します。
offset が負の場合は、文字列の末尾から数えた位置から探索します。
byterindex と String#byteindex とでは、探索方向だけが逆になります。
完全に左右が反転した動作をするわけではありません。
探......yterindex('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
$~... -
static void special
_ local _ set(char c , VALUE val) (6132.0) -
$~ と $_ をセットします。 現在は c=0 が $_ で c=1 が $~ です。
...
$~ と $_ をセットします。
現在は c=0 が $_ で c=1 が $~ です。... -
VALUE rb
_ backref _ get(void) (6116.0) -
現在の SCOPE の $~ の値を返します。
...現在の SCOPE の $~ の値を返します。... -
void rb
_ backref _ set(VALUE val) (6116.0) -
現在の SCOPE の $~ に val を代入します。
...現在の SCOPE の $~ に val を代入します。... -
MatchData
# to _ s -> String (6106.0) -
マッチした文字列全体を返します。
...マッチした文字列全体を返します。
//emlist[例][ruby]{
/bar/ =~ "foobarbaz"
p $~ # => #<MatchData:0x401b1be4>
p $~.to_s # => "bar"
//}... -
StringScanner (6030.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......can(/\s+/) #=> " "
p s.scan(/\w+/) #=> "example"
p s.scan(/\s+/) #=> " "
p s.scan(/\w+/) #=> "string"
s.eos? #=> true
p s.scan(/\s+/) #=> nil
p s.scan(/\w+/) #=> nil
//}
StringScanner オブジェクトはスキャンする文字列と「スキャンポインタ」のセッ......す。
//emlist[例:][ruby]{
# 次の行以降の内容を EUC-JP として保存して試してください
# vim:set fileencoding=euc-jp:
require 'strscan'
s = StringScanner.new("るびい") # 文字コードはEUC-JPとします
p s.exist?(/び/) #=> 4
//}
StringScanner は $~ $& $1 $2 ……... -
ruby 1
. 6 feature (3276.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...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 とは異なる挙動です......1.step(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 を... -
Regexp
. compile(string , option = nil) -> Regexp (142.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...string をコンパイルして正規表現オブジェクトを生成して返します。
第一引数が正規表現であれば第一引数を複製して返します。第二引数は警告の上無視されます。
@param string 正規表現を文字列として与えます。
@param opti......on Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp::IGNORECASE の指定と......st[例][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
\ regexp # ここも使用されない
', Regexp::EXTENDED | Regexp::IGNORECASE)
t2.matc... -
Regexp
. compile(string , option = nil , code = nil) -> Regexp (142.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
第一引数が正規表現であれば第一引数を複製して返します。第二、第三引数は警告の上無視されます。
@param string 正規表現を文字列として与えま......す。
@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp::IGNORE......BIT になります。
それ以外の指定は警告を出力します。
@raise RegexpError 正規表現のコンパイルに失敗した場合発生します。
//emlist[例][ruby]{
str = "This is Regexp"
t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1.match(str)
p $~... -
Regexp
. new(string , option = nil) -> Regexp (142.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...string をコンパイルして正規表現オブジェクトを生成して返します。
第一引数が正規表現であれば第一引数を複製して返します。第二引数は警告の上無視されます。
@param string 正規表現を文字列として与えます。
@param opti......on Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp::IGNORECASE の指定と......st[例][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
\ regexp # ここも使用されない
', Regexp::EXTENDED | Regexp::IGNORECASE)
t2.matc...