Rubyでは正規表現オブジェクトというものがあります
raddr = "^(\d+)\.(\d+)\.(\d+)\.(\d+)$"
regexp = Regrexp.new(raddr)
if regexp =~ "192.168.0.1"
puts "まっち"
end

リファレンス: google ruby regexp(本家が503エラーの時はキャッシュをみてくれ)
http://www.google.com/search?hl=ja&client=opera&rls=ja&hs=GDL&q=ruby+regexp

標準添付ライブラリ紹介 【第 12 回】 正規表現 (1)
http://jp.rubyist.net/magazine/?0019-BundledLibraries
#以下引用
| Regexp.new("\\n")
| Regexp.new('\n')
| Regexp.new('\\n')
| などです。 この 3 つは文字列リテラルの書き方の違いだけで、
| 「Regexp.new」の引数に渡るオブジェクトの内容は同じです。