タグ

rubyと正規表現に関するkgbuのブックマーク (4)

  • unicode の大文字小文字は大変だなあ - まめめも

    ちょっと調べただけですが、面白かったのでメモ。世界は広いですね。バベルの塔ですね。 ß ドイツ語では、ß (U+00DF 、エスツェット) を大文字にすると SS になるらしい。 鬼車 (RubyPHP で使われている正規表現エンジン) はこれに対応していて、ignore case にすると、一文字が複数の文字にマッチして驚く。 # coding: UTF-8 p "-SS-"[/-\u00DF-/i] #=> "-SS-" p "-\u00DF-"[/-SS-/i] #=> "-\u00DF-" こういう関係の字は他にもあるみたい。 ref: ftp://ftp.unicode.org/Public/UNIDATA/SpecialCasing.txt İ と ı トルコ語やアゼルバイジャン語では i と I が別の字らしい。i の大文字は İ (U+0130 、点つきの I) で、

    unicode の大文字小文字は大変だなあ - まめめも
    kgbu
    kgbu 2008/12/06
    小文字では1文字、大文字では2文字とか、Iとiは別の字だとか、アルファベットは奥が深いんだな。
  • 正規表現利用間に合わせパーサ | tnomuraのブログ

    正規表現を利用した、ちょこっとまにあわせパーサができた。 使い方だが、まず、スキャナーの字句解析ルールを設定した配列を引数にして、Lex クラスのオブジェクトを作る。lex.buf = "(1 + 2) + 3" のように、Lex オブジェクトのバッファに、解析したい文字列を入れると、lex.get を実行するたびに、戻り値としてトークンと値が帰ってくる。 字句解析ルールは[ 正規表現によるパターン, トークン名(英字一文字), 値を戻すときの処理]という配列の配列だ。値を戻すときの処理は、たとえば数値データなどで文字列を数値にするときなどに使う。トークン名を英字一文字にしたことによってパーサのデータの処理が正規表現を使ってできる。 次にパーサのルールを設定するが、パーサのルールは、[トークンのパターン, パターンが一致して縮約するときのトークン, パターンが一致したときの値の処理] とい

    正規表現利用間に合わせパーサ | tnomuraのブログ
  • PragDave: Fun with Ruby 1.9 Regular Expressions

    I've reorganized the regular expression content in the new Programming Ruby, and added some cool new advanced examples. This one's fairly straightforward, but I love the fact that I can now start refactoring my more complex patterns, removing duplication. The stuff below is an extract from the unedited update. It'll appear in the next beta. It follows a discussion of named groups, \k and related

  • Will's Code

    emacs GNU emacs is likely the most useful program written in the past 20 years. It isn't a text editor as much as a lisp engine with powerful text and display management functionality. emacs makes a great platform for writing apps that use a text interface. ssh-agent.el - runs ssh-agent from within emacs, setting the proper env variables. Also execute ssh-add and prompt the user for any requested

    kgbu
    kgbu 2008/06/17
    Erlangでport driverとして使える正規表現ライブラリらしい。Rubyで使われているonigurumaがその実体らしい。
  • 1