タグ

regexpに関するmrknのブックマーク (2)

  • Regex that only matches itself

    There are some pretty cool challenges out there involving regex (Self-matching regex, Regex validating regex) This may well be impossible, but is there a regex that will ONLY match itself? NOTE, delimiters must be included: for example /thing/ must match /thing/ and not thing. The only match possible for your expression must be the expression itself. Many languages allow the implementation of a st

    Regex that only matches itself
    mrkn
    mrkn 2016/11/12
    自分自身だけにマッチする正規表現
  • Ruby | やぐにっき

    railsのログを読んでいたら、Rack::Utils#escapeで下記warningが大量に出ていた。 warning: regexp match /.../n against to UTF-8 string 正規表現でn修飾子を利用しているのが問題のようで。 n修飾子は文字コードを考えずに、バイトコードとして判別しますよーというもの 参考: 正規表現メモ: Rubyの正規表現 その他の修飾子 s: 文字コードにShiftJISを指定 e: 文字コードにEUC-JPを指定 u: 文字コードにUTF-8を指定 n: 文字コードを指定しない(単なるバイト列として扱う) o: 最初に到達したときのみ式展開・コンパイルを行う 1.9ではStringにEncodingオブジェクトを持つようになったので、何らかの文字コードは指定されているのが当たり前という風にするしかない。 そこでここの部分を

    mrkn
    mrkn 2011/12/09
    too short escaped multibyte character 問題
  • 1