Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

2014-10-15から1日間の記事一覧

正規表現の後方読み

Rubyにも、後方一致というオプションがついてます。 これを使うと、特定パターンに続く文字列を抽出する事が可能となります /(?<=<b>)\w+(?=<\/b>)/.match("Fortune favours the <b>bold</b>") # => #<MatchData "bold"> 参考もと 正規表現 ruby - Is there any way to shorten this regu</matchdata></b>…