別のキーワード
ライブラリ
- ビルトイン (162)
-
irb
/ cmd / help (12) - stringio (24)
- strscan (156)
クラス
-
IRB
:: ExtendCommand :: Help (12) - MatchData (12)
- String (141)
- StringIO (24)
- StringScanner (156)
- Symbol (9)
キーワード
- charpos (12)
- check (12)
-
check
_ until (12) - clear (12)
- execute (12)
- index (12)
- insert (12)
- match (24)
- match? (18)
- pointer (12)
- pointer= (12)
- pos= (24)
-
post
_ match (24) - reset (12)
- rindex (12)
-
scan
_ until (12) -
skip
_ until (12) - slice! (72)
- terminate (12)
- ungetc (12)
検索結果
先頭5件
-
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"
//}...