クラス
- Regexp (22)
モジュール
- Kernel (11)
キーワード
-
$ LAST _ PAREN _ MATCH (11) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - new (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 4 feature (11) - 正規表現 (11)
検索結果
先頭5件
-
Regexp
. compile(string , option = nil , code = nil) -> Regexp (18267.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
第一引数が正規表現であれば第一引数を複製して返します。第二、第三引数は警告の上無視されます。
@param string 正規表現を文字列として与えま......t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1.match(str)
p $~ # => "This is Regexp"
t2 = Regexp.compile('
this # ここは使用されない
\ is
\ regexp # ここも使用されない
', Regexp::EXTENDED | Regexp::IGNORECASE)
t2.match(str)
p Regexp.last_match # => "This......is Regexp"
str = "ふるいけや\nかわずとびこむ\nみずのおと"
t2 = Regexp.compile("ふる.*?と", Regexp::MULTILINE)
p t2.match(str)[0] # => "ふるいけや\nかわずと"
//}... -
Kernel
$ $ LAST _ PAREN _ MATCH -> String | nil (6214.0) -
$+ の別名
...$+ の別名
require "English"
r1 = Regexp.compile("<img src=(http:.+?)>")
r2 = Regexp.compile("<a href=(http|ftp).+?>(.+?)</a>")
while line = DATA.gets
[ r1, r2 ].each {|rep|
rep =~ line
p $+
}
end
__END__
<tr> <td><img src=http://localhost/a.jpg></td> <td>ikko... -
Regexp
. new(string , option = nil , code = nil) -> Regexp (3167.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
第一引数が正規表現であれば第一引数を複製して返します。第二、第三引数は警告の上無視されます。
@param string 正規表現を文字列として与えま......t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1.match(str)
p $~ # => "This is Regexp"
t2 = Regexp.compile('
this # ここは使用されない
\ is
\ regexp # ここも使用されない
', Regexp::EXTENDED | Regexp::IGNORECASE)
t2.match(str)
p Regexp.last_match # => "This......is Regexp"
str = "ふるいけや\nかわずとびこむ\nみずのおと"
t2 = Regexp.compile("ふる.*?と", Regexp::MULTILINE)
p t2.match(str)[0] # => "ふるいけや\nかわずと"
//}... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (702.0) -
1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))
...fix として 0d が追加されました。
8進リテラルの prefix として 0 以外に 0o が追加されました。
Integer(), String#to_i、String#oct もこの prefix を認識します。
: ((<メソッド引数の & 修飾|メソッド呼び出し/イテレータ>)) [compat]
: ((<......: ((<File/File.extname>)) [new]
追加。ファイル名の拡張子を返します。((<ruby-talk:37617>))
: ((<File/File.fnmatch>)) [new]
: ((<File/File.fnmatch?>)) [new]
追加
このメソッドで使用するフラグ FNM_NOESCAPE, FNM_PATHNAME, FNM_PERIOD,
FNM_CASEFOLD も((......になりました。(よ
り正確には、Regexp.compile(arg) でなく
Regexp.compile(Regexp.quote(arg)) するようになりました)
((<String#~|String/~>)), ((<String#=~|String/=~>)) は、obsolete にな
りました。(String#~ はここにあげた変更が反映された上で o... -
正規表現 (478.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 ex......lace}/.match("Go to 東京都") # => #<MatchData "東京都">
//}
埋め込んだ文字列にメタ文字が含まれているならば、それは
メタ文字として認識されます。
//emlist[][ruby]{
number = "(\\d+)"
operator = "(\\+|-|\\*|/)"
/#{number}#{operator}#{number}/.match("43+29......mlist[][ruby]{
/\A(?<a>|.|(?:(?<b>.)\g<a>\k<b+0>))\z/.match("rekxker")
# => #<MatchData "rekxker" a:"rekxker" b:"k">
//}
以下の例では、開始タグと終了タグを対応付ける正規表現です。
//emlist[][ruby]{
r = Regexp.compile(<<'__REGEXP__'.strip, Regexp::EXTENDED)
(?<element>... -
ruby 1
. 6 feature (318.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......foo = "foo"
p foo["bar"] = "baz"
p foo
=> ruby 1.6.7 (2002-03-01) [i586-linux]
"baz"
"foo"
=> -:2:in `[]=': string not matched (IndexError)
from -:2
ruby 1.6.7 (2002-07-30) [i586-linux]
: 2002-06-03 sprintf()
"%d" で引数を整数にする......がありました。
((<ruby-list:34478>))
#! ruby -Ks
p a = "#{"表"}"
=> -:1: compile error in string expansion (SyntaxError)
-:1: unterminated string meets end of file
ruby 1.6.7 (2002-03-15) [i586-linux]
=> ruby 1.6.7 (2002-03-19) [i586-l... -
ruby 1
. 8 . 4 feature (102.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
...e (Win全般) [bug]>))
* ((<ruby 1.8.4 feature/File::Stat#pipe? [bug]>))
* ((<ruby 1.8.4 feature/Array#fill [bug]>))
* ((<ruby 1.8.4 feature/String#scan [bug]>))
* ((<ruby 1.8.4 feature/File.join [bug]>))
* ((<ruby 1.8.4 feature/Thread#pass [bug]>))
* ((<ruby 1.8.4 feature/Module#const_m......3: warning: too many arguments for format string
: super: no superclass method `foo' (NoMethodError)
from -:7
: 正規表現 [bug]
#Wed Oct 19 01:27:07 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
#
# * regex.c (re_compile_pattern): numeric literal inside charact......:27818>))
: optparse
#Tue Nov 22 23:52:06 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
#
# * lib/optparse.rb: match incomplete (in current enconding) multibyte
# string. http://inamode6.tokuhirom.dnsalias.org/show/1551
$KCODEで無効なマルチバイト文字列や、改行...