ドットインストール代表のライフハックブログ
おっと、これは便利かも。 REGEXPERを使えば、JavaScriptの正規表現をわかりやすく表現してくれる。 一見、難解な正規表現だが、これを通しても見ると「なるほど、この文字とこの文字にはされまれていて、この間は何の文字でも良いのだな」といったことがわかるようになる。 他の人のコードを読んでいて「?」となったときに試してみてもいいかもですな。
この記事は Python Tips Advent Calendar 2012 24日目の記事です。 Python の正規表現には、便利な機能がいくつかあります。ということで、いくつか見ていきましょう。 コメント機能 >>> import re >>> re.compile(r''' ... ^ # start of a line ... \[font # the font tag ... (?:=(?P<size> # optional [font=+size] ... [-+][0-9]{1,2} # size specification ... ))? ... \] # end of tag ... (.*?) # text between the tags ... \[/font\] # end of the tag ... ''', re.VERBOSE) #doctest: +E
Shibuya.pm #16 「夏の正規表現祭り」で、正規表現のお話をさせていただきました。 まぁ、「電話番号にマッチする正規表現」とか「郵便番号にマッチする正規表現」とかよく書かれてるけど、「どれもこれも手緩いよね」って話。 あ、だいぶはしょったかな。 とりあえずスライドに書いたので、発表をご覧になってない方はスライドからご覧ください。 ふと見返すと、このブログで電話番号の正規表現を公表するのは 3 度目ですが、あれからだいぶ経ってますね。 今ではもっと厳密な正規表現を作っています。 そして、Number::Phone::JP に続き、Number::ZipCode::JP という酔狂なモジュールが公開された記念で、郵便番号にマッチする正規表現を今回初めて公開しますが、そもそもここまで厳密な正規表現が公開されること自体、本邦初公開ってヤツでしょう。 Shibuya.pm でも言いましたが
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く