るりまサーチ

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

別のキーワード

  1. format spec=
  2. format spec
  3. installer spec
  4. oldformat spec
  5. oldformat spec=

ライブラリ

検索結果

Regexp (7.0)

正規表現のクラス。正規表現のリテラルはスラッシュで囲んだ形式 で記述します。

...現オブジェクトを動的に生成する
こともできます。

//emlist[][ruby]{
str = "this is regexp"
rp1 = Regexp.new("^this is regexp")
p rp1 =~ str # => 0
p Regexp.last_match[0] # => "this is regexp"
//}


spec/regexp
や d:spec/literal#regexp も参照してください。...
..."this is regexp"
//}

Ruby 3.0.0 から正規表現リテラルは freeze されるようになりました。
//emlist[][ruby]{
p /abc/.frozen?
# => true
p /a#{42}bc/.frozen?
# => true
p Regexp.new('abc').frozen?
# => false
//}

spec/regexp
や d:spec/literal#regexp も参照してください。...