るりまサーチ

最速Rubyリファレンスマニュアル検索!
137件ヒット [1-100件を表示] (0.064秒)
トップページ > クエリ:string[x] > クエリ:ref[x] > クエリ:Regexp[x]

別のキーワード

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

検索結果

<< 1 2 > >>

Regexp (38072.0)

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

...is regexp/
//}

Regexp
.new(string) を使って正規表現オブジェクトを動的に生成する
こともできます。

//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/
//}

Regexp
.new(string) を使って正規表現オブジェクトを動的に生成する
こともできます。

//emlist[][ruby]{
str = "this is regexp"
rp1 = Regexp.new("^this is regexp")
p rp1 =~ str # => 0
p Regexp.last_match[0] # => "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 も参照してください。...

String#scanf(format) -> Array (9030.0)

ブロックを指定しない場合、見つかった文字列を format に従って変 換し、そのオブジェクトの配列を返します。 format で指定した文字列が見つからない場合は空の配列を 生成して返します。

...il], ["abc", 456], ["def", nil]]


@param format スキャンするフォーマットを文字列で指定します。
詳細は、m:String#scanf#format を参照してください。

使用例:
require 'scanf'
str = "123 abc 456 def 789 ghi"
p str.scanf("%d%s") #=> [123, "abc"]...
...%a
: %A
符号付き浮動小数点数

: %s
空白文字を含まない文字列
(幅が指定されているときは指定された文字数か空白文字の直前までの短い方)

: %c
1文字(幅が指定されているときは指定された文字数)

: [...]
d:spec/regexp#string...

String#scanf(format) {|*ary| ...} -> Array (9030.0)

ブロックを指定しない場合、見つかった文字列を format に従って変 換し、そのオブジェクトの配列を返します。 format で指定した文字列が見つからない場合は空の配列を 生成して返します。

...il], ["abc", 456], ["def", nil]]


@param format スキャンするフォーマットを文字列で指定します。
詳細は、m:String#scanf#format を参照してください。

使用例:
require 'scanf'
str = "123 abc 456 def 789 ghi"
p str.scanf("%d%s") #=> [123, "abc"]...
...%a
: %A
符号付き浮動小数点数

: %s
空白文字を含まない文字列
(幅が指定されているときは指定された文字数か空白文字の直前までの短い方)

: %c
1文字(幅が指定されているときは指定された文字数)

: [...]
d:spec/regexp#string...

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (3788.0)

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) ex q num per and or  plus minus ast slash hat sq  period comma langl rangl eq tilde  dollar at under lbrarbra  lbra2rbra2 lbra3rbra3 dq colon ac  backslash semicolon

...: /xxx/ !~ yyy

正規表現のメソッド =~ の否定。マッチが失敗したらtrueを返します。


===[a:q] ?

: ?a

d:spec/literal#string。長さ 1 の文字列。

: def xx?

この場合の「?」はメソッド名の一部分です。
慣用的に、真偽値を返すタイプ...
...算子。整数クラスでは「剰余」を意味するメソッド。Numeric#%メソッドなどを参照。

: "%04b" % 10

String
クラスの「%」演算子。String#% メソッド。文字列中ではフォーマット指定子としても使われる。

: %r{/etc/httpd/logs$} や %w[foo b...
.../etc/httpd/logs$} #=> /\/etc\/httpd\/logs$/
p %w[foo bar baz] #=> ["foo", "bar", "baz"]
//}

: %!STRING!

% 記法の一種。d:spec/literal#percent。ダブルクォート文字列で %Q!STRING! と同じ。
//emlist{
p %!nomad! #=> "nomad"
//}

: % ruby -e "puts 'Hello'"

コマンドラ...

正規表現 (3550.0)

正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references

...* metachar
* expansion
* char
* anychar
* string
* str
* quantifier
* capture
* grouping
* subexp
* selector
* anchor
* cond
* option
* encoding
* comment
* free_format_mode
* absenceop
* list
* specialvar
* references


正規表現(regular expression)は文...
...文字列中のどの場所であるかを知ることができます。

//emlist[][ruby]{
/pat/
%r{pat}
//}

などの正規表現リテラルや Regexp.new などで正規表現
オブジェクトを得ることができます。


===[a:metachar] メタ文字列とリテラル、メタ文字と...
...以外の
その文字列そのものにマッチするような文字列があります。
前者をメタ文字列(meta string)、後者をリテラル(文字列)(literal string)と呼びます。

//emlist[][ruby]{
/京都|大阪|神戸/
//}

という正規表現においては、「京都」「...

絞り込み条件を変える

リテラル (606.0)

リテラル * num * string * backslash * exp * char * command * here * regexp * array * hash * range * symbol * percent

...リテラル
* num
* string
* backslash
* exp
* char
* command
* here
* regexp
* array
* hash
* range
* symbol
* percent

数字の1や文字列"hello world"のようにRubyのプログラムの中に直接
記述できる値の事をリテラルといいます。

===[a:n...
...
前(符号(+,-)の直後を含む)に _を置くとローカル変数やメソッド呼び
出しと解釈されます)

_ は、0x などの prefix の直後に書くことはできません。また、_ を連続して
書いてもエラーになります。他、細かい部分でこのあた...
...string] 文字列リテラル

//emlist[例][ruby]{
"this is a string expression\n"
'this is a string expression\n'
%q!I said, "You said, 'She said it.'"!
%!I said, "You said, 'She said it.'"!
%Q('This is it.'\n)
"this is multi line
string
"
//}

文字列はダブルクォートまたはシングル...

Ruby用語集 (510.0)

Ruby用語集 A B C D E F G I J M N O R S Y

...cent

: 0 オリジン
: zero-based
番号が 0 から始まること。

例えば、
Array や Vector、Matrix などの要素の番号、
String
における文字の位置、
といったものは 0 オリジンである。

: 1 オリジン
: one-based
番号が 1 から始まるこ...
...し、合わせてドキュメントの HTML を生成する。

参照:rdoc

: refinement
既存のクラスやモジュールを特定のスコープでのみ改変する仕組み。

参照:Module#refine、Module#using、main.using

: Ruby Central
Rubyのサポートと世界の Ruby...
...照:spec/safelevel

: 鬼雲
: Onigmo
Ruby 2.0 以降採用されている正規表現エンジン。鬼車のフォーク。

参照:spec/regexp

: 鬼車
: Oniguruma
Ruby 1.9.x で採用されていた正規表現エンジン。

: オーバーライド
: override
Ruby では上位ク...
...削除された。


: 鬼雲
: Onigmo
Ruby 2.0 以降採用されている正規表現エンジン。鬼車のフォーク。

参照:spec/regexp

: 鬼車
: Oniguruma
Ruby 1.9.x で採用されていた正規表現エンジン。

: オーバーライド
: override
Ruby では上位ク...

ruby 1.6 feature (414.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...りました。

p "#{ "" }"

=> ruby 1.6.7 (2002-03-01) [i586-linux]
""

=> -:1: warning: bad substitution in string
ruby 1.6.7 (2002-09-12) [i586-linux]
"#{ }"

=> ruby 1.6.7 (2002-09-25) [i586-linux]
""

これは1.7...
...: 2002-05-02 Regexp.quote

# はバックスラッシュクォートするようになりました。これは、quote した
正規表現を //x に正しく埋め込めるようにするためです。
((<ruby-bugs-ja:PR#231>))

p Regexp.quote("#")

p /a#{Regexp.quote("#")}b...
...ameError)
from -:2
ruby 1.6.7 (2002-03-01) [i586-linux]

=> ruby 1.6.7 (2002-03-15) [i586-linux]

: 2002-03-13 ((<getopts>))

ref
ine. ((<ruby-dev:16193>)), ((<ruby-dev:16213>))

: 2002-03-11 正規表現中の 8 進コード

正規表現中の \nnn による 8 進記法...

NEWS for Ruby 3.0.0 (294.0)

NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...", "f", 3]
in [*pre, String => x, String => y, *post]
p pre #=> ["a", 1]
p x #=> "b"
p y #=> "c"
p post #=> [2, "d", "e", "f", 3]
end
//}

* Endless method definition is added. [EXPERIMENTAL]
16746

//emlist{
def square(x) = x * x
//}

* Interpolated String literals are no lo...
...nger frozen when
`# frozen-string-literal: true` is used. 17104
* Magic comment `shareable_constant_value` added to freeze constants.
See {Magic Comments}[rdoc-ref:doc/syntax/comments.rdoc@Magic+Comments] for more details.
17273
* A {static analysis}[rdoc-label:label-Static+analysis]...
...3.2.3
* StringIO
* Update to StringIO 3.0.0
* This version is Ractor compatible.
* StringScanner
* Update to StringScanner 3.0.0
* This version is Ractor compatible.

== Compatibility issues

Excluding feature bug fixes.

* Regexp literals and all Range objects are frozen. 894...

Marshal フォーマット (108.0)

Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。

...==== String, Regexp, Array, Hash のサブクラス (インスタンス変数なし)

'C' で始まるデータ構造になります。

//emlist{
| 'C' | クラス名(Symbol)の dump | 親クラスのインスタンスの dump |
//}

//emlist[例 1][ruby]{
class Foo < Array # (or String, Regexp, Ha...
...==== String, Regexp, Array, Hash のサブクラス (インスタンス変数あり)

'I' で始まるデータ構造になります。
d:marshal_format#instance_variableも参照してください。

//emlist[例 2: インスタンス変数あり][ruby]{
class Foo < Array # (or String, Regexp, Ha...
...)
# => ["l", "+", 8, "\x00\x00\x00\x00\x01\x00"]
//}

ruby 1.6.3 では ["l", "+", 8, "\000\000\001\000"] になるバグがありました。

=== String

'"' で始まるデータ構造になります。

//emlist{
| '"' | 長さ(Fixnum形式) | 文字列 |
//}

//emlist[例: ascii-8bit の時 (1....

絞り込み条件を変える

<< 1 2 > >>