るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

StringScanner#pos -> Integer (21238.0)

現在のスキャンポインタのインデックスを返します。

...デックスを返します。

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

s = StringScanner.new('test string')
s.pos # => 0
s.scan(/\w+/) # => "test"
s.pos # => 4
s.scan(/\w+/) # => nil
s.pos # => 4
s.scan(/\s+/) # => " "
s.pos # => 5
//}

@see StringScanner#charpos...

String#match(regexp, pos = 0) -> MatchData | nil (15343.0)

regexp.match(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match を参照してください。

...regexp.match(self, pos) と同じです。
regexp が文字列の場合は、正規表現にコンパイルします。
詳しくは Regexp#match を参照してください。

//emlist[例: regexp のみの場合][ruby]{
'hello'.match('(.)\1') # => #<MatchData "ll" 1:"l">
'hello'.match('(.)\1...
...ll"
'hello'.match(/(.)\1/)[0] # => "ll"
'hello'.match('xx') # => nil
//}

//emlist[例: regexp, pos を指定した場合][ruby]{
'hoge hige hege bar'.match('h.ge', 0) # => #<MatchData "hoge">
'hoge hige hege bar'.match('h.ge', 1) # => #<MatchData "hige">
//}

//emlist[例: ブロ...
...ックを指定した場合][ruby]{
'hello'.match('(.)\1'){|e|"match #{$1}"} # => "match l"
'hello'.match('xx'){|e|"match #{$1}"} # マッチしないためブロックは実行されない
//}

@see Regexp#match, Symbol#match...

StringScanner#post_match -> String | nil (15332.0)

前回マッチを行った文字列のうち、マッチしたところよりも後ろの 部分文字列を返します。前回のマッチが失敗していると常に nil を 返します。

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

s = StringScanner.new('test string')
s.post_match # => nil
s.scan(/\w+/) # => "test"
s.post_match # => " string"
s.scan(/\w+/) # => nil
s.post_match # => nil
s.scan(/\s+/) # => " "
s.post_match # => "string"
s.scan(/\w+/) # => "string"
s.post_match # =>...
...""
s.scan(/\w+/) # => nil
s.post_match # => nil
//}...

MatchData#post_match -> String (15308.0)

マッチした部分より後ろの文字列を返します($'と同じ)。

...マッチした部分より後ろの文字列を返します($'と同じ)。

//emlist[例][ruby]{
/(bar)(BAZ)?/ =~ "foobarbaz"
p $~.post_match # => "baz"
//}

@see MatchData#pre_match...

String#insert(pos, other) -> self (15252.0)

pos 番目の文字の直前に文字列 other を挿入します。 self[pos, 0] = other と同じ操作です。

...
pos
番目の文字の直前に文字列 other を挿入します。
self[pos, 0] = other と同じ操作です。

@param pos 文字列を挿入するインデックス
@param other 挿入する文字列

//emlist[例][ruby]{
str = "foobaz"
str.insert(3, "bar")
p str # => "foobarbaz"
//}...
...@see String#[]=...

絞り込み条件を変える

String#match(regexp, pos = 0) {|m| ... } -> object (15243.0)

regexp.match(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match を参照してください。

...regexp.match(self, pos) と同じです。
regexp が文字列の場合は、正規表現にコンパイルします。
詳しくは Regexp#match を参照してください。

//emlist[例: regexp のみの場合][ruby]{
'hello'.match('(.)\1') # => #<MatchData "ll" 1:"l">
'hello'.match('(.)\1...
...ll"
'hello'.match(/(.)\1/)[0] # => "ll"
'hello'.match('xx') # => nil
//}

//emlist[例: regexp, pos を指定した場合][ruby]{
'hoge hige hege bar'.match('h.ge', 0) # => #<MatchData "hoge">
'hoge hige hege bar'.match('h.ge', 1) # => #<MatchData "hige">
//}

//emlist[例: ブロ...
...ックを指定した場合][ruby]{
'hello'.match('(.)\1'){|e|"match #{$1}"} # => "match l"
'hello'.match('xx'){|e|"match #{$1}"} # マッチしないためブロックは実行されない
//}

@see Regexp#match, Symbol#match...

String#match?(regexp, pos = 0) -> bool (15242.0)

regexp.match?(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match? を参照してください。

...regexp.match?(self, pos) と同じです。
regexp が文字列の場合は、正規表現にコンパイルします。
詳しくは Regexp#match? を参照してください。

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

@see Regexp#match?, Symbol#match?...

String#slice!(pos, len) -> String (12378.0)

指定した範囲 (String#[] 参照) を 文字列から取り除いたうえで取り除いた部分文字列を返します。

...(String#[] 参照) を
文字列から取り除いたうえで取り除いた部分文字列を返します。

引数が範囲外を指す場合は nil を返します。

//emlist[例][ruby]{
string
= "this is a string"
string
.slice!(2) #=> "i"
string
.slice!(3..6) #=> " is "
string
.sl...
...ice!(/s.*t/) #=> "sa st"
string
.slice!("r") #=> "r"
string
#=> "thing"
//}...

String#slice!(substr) -> String (12378.0)

指定した範囲 (String#[] 参照) を 文字列から取り除いたうえで取り除いた部分文字列を返します。

...(String#[] 参照) を
文字列から取り除いたうえで取り除いた部分文字列を返します。

引数が範囲外を指す場合は nil を返します。

//emlist[例][ruby]{
string
= "this is a string"
string
.slice!(2) #=> "i"
string
.slice!(3..6) #=> " is "
string
.sl...
...ice!(/s.*t/) #=> "sa st"
string
.slice!("r") #=> "r"
string
#=> "thing"
//}...
<< 1 2 3 ... > >>