Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

2012-06-05から1日間の記事一覧

書籍 Regular Expressions Cookbook | Escape Regular Expression Metacharacters

パンくず 書籍 Regular Expressions Cookbook Escape Regular Expression Metacharacters 概要 正規表現のエスケープについて サンプル str = '\n[]|^!?+' puts str puts "-------------------------" puts Regexp.escape(str) 出力 \n[]|^!?+ -------------…

書籍 Regular Expressions Cookbook | Match Complete Lines That Do Not Contain a Word

パンくず 書籍 Regular Expressions Cookbook Match Complete Lines That Do Not Contain a Word 概要 ある単語を含まない行について サンプル str =<<"EOS" line1 kuroko line2 EOS puts str puts "------------------------------------" print str.gsub(/…

書籍 Regular Expressions Cookbook | Match Complete Lines That Contain a Word

パンくず 書籍 Regular Expressions Cookbook Match Complete Lines That Contain a Word 概要 ある単語を含む行について サンプル # encoding: Windows-31J require "pp" str =<<"EOS" line1 kuroko line2 EOS puts str puts "----------------------------…

書籍 Regular Expressions Cookbook | Remove Duplicate Lines

パンくず 書籍 Regular Expressions Cookbook Remove Duplicate Lines 概要 重複行の削除について サンプル str =<<"EOS" line1 line1 line2 EOS puts str puts "------------------------------------" print str.gsub(/^(.*)(?:(?:\r?\n|\n)\1)+/,"") 出力…

書籍 Regular Expressions Cookbook | Find Repeated Words

パンくず 書籍 Regular Expressions Cookbook Find Repeated Words 概要 単語の繰り返しのマッチングについて サンプル print "オラ オラ 無駄 無駄".scan(/\b(オラ+)\s+\1\b/) 出力 [["オラ"]]