るりまサーチ

最速Rubyリファレンスマニュアル検索!
354件ヒット [101-200件を表示] (0.061秒)
トップページ > クエリ:ruby[x] > クエリ:String[x] > クエリ:string[x] > クエリ:pos[x] > 種類:インスタンスメソッド[x]

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub

ライブラリ

クラス

キーワード

検索結果

<< < 1 2 3 4 > >>

String#index(pattern, pos = 0) -> Integer | nil (30148.0)

文字列のインデックス pos から右に向かって pattern を検索し、 最初に見つかった部分文字列の左端のインデックスを返します。 見つからなければ nil を返します。

...ックス pos から右に向かって pattern を検索し、
最初に見つかった部分文字列の左端のインデックスを返します。
見つからなければ nil を返します。

引数 pattern は探索する部分文字列または正規表現で指定します。

pos
が負...
...数えた位置から探索します。

@param pattern 探索する部分文字列または正規表現
@param pos 探索を開始するインデックス

//emlist[例][ruby]{
p "astrochemistry".index("str") # => 1
p "regexpindex".index(/e.*x/, 2) # => 3
p "character".inde...
...x(?c) # => 0

p "foobarfoobar".index("bar", 6) # => 9
p "foobarfoobar".index("bar", -6) # => 9
//}

@see String#rindex...

String#match(regexp, pos = 0) -> MatchData | nil (30143.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('(.)\...
...# => 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...

String#match(regexp, pos = 0) {|m| ... } -> object (30143.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('(.)\...
...# => 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...

String#match?(regexp, pos = 0) -> bool (30142.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.../) #=>...

StringScanner#pos -> Integer (21144.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...

絞り込み条件を変える

StringScanner#post_match -> String | nil (12357.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
//}...

StringIO#pos=(n) (12126.0)

自身の位置を n に移動します。自身が表す文字列のサイズより大きくても構いません。

...@param n 自身の位置を整数で指定します。

@raise Errno::EINVAL n がマイナスである場合に発生します。

//emlist[例][ruby]{
require "stringio"
a = StringIO.new("hoge", 'r+')
a.pos = 10
a << 'Z'
a.string #=> "hoge\000\000\000\000\000\000Z"
//}...

StringScanner#charpos -> Integer (12119.0)

現在のスキャンポインタのインデックスを文字単位で返します。

...キャンポインタのインデックスを文字単位で返します。

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

s = StringScanner.new("abcädeföghi")
s.charpos # => 0
s.scan_until(/ä/) # => "abcä"
s.pos # => 5
s.charpos # => 4
//}

@see StringScanner#pos...

StringScanner#pos=(n) (9144.0)

スキャンポインタのインデックスを n にセットします。

...ist[例][ruby]{
require 'strscan'

s = StringScanner.new('test string')
p s.scan(/\w+/) # => "test"
p s.pos = 1 # => 1
p s.scan(/\w+/) # => "est"
p s.pos = 7 # => 7
p s.scan(/\w+/) # => "ring"

begin
s.pos = 20
rescue RangeError => err
puts err #=> index out of range
end
p s.pos = -4...
<< < 1 2 3 4 > >>