タグ

programmingとRegexpに関するseamlessbiasのブックマーク (2)

  • Regular Expression Tool

    RegExp Global Multiline Ignore case Sample Text ? Result . any character except a newline \d any decimal digit \D any non-digit \s any whitespace character \S any non-whitespace characte \w any alphanumeric character \W any non-alphanumeric character \number the contents of the group with the given number * zero or more of the preceding block *? zero or more of the preceding block (non-greedy) + o

  • テスト駆動で 0 から 255 の数字にマッチする正規表現へ変形してみる - Tociyuki::Diary

    ぶくま経由で、RFC 3986 URI の日語訳にたどり着き、読んでいました。スムーズな日語ですんなりと読めて、良い訳だと思いました。私は誤訳を見つけられませんでした。 それはともかく、読んでいる最中に、RFC3986 だけではないのですが、IPv4 アドレスの数字にマッチする構文が、正規表現向けでないのに改めて気になりました。RFC の記述をそのまま正規表現にすると、バックトラックをおこす書き方になっています。 バックトラックがおきないようにするには、先頭から1文字ずつ見ていくだけで残りの選択肢のどれに進めばいいか決定できるようにすればよろしい。ということで、これをテスト駆動で正規表現に向いた記述に変更してみました。 ⇒ http://www.studyinghttp.net/cgi-bin/rfc.cgi?3986#Sec3.2.2 IPv4address = dec-octet

    テスト駆動で 0 から 255 の数字にマッチする正規表現へ変形してみる - Tociyuki::Diary
    seamlessbias
    seamlessbias 2007/02/01
    テスト駆動開発。
  • 1