I wrote following piece of Ruby code which is used to extract information from an html page.
combined = state = county = special = 0
unless options.nil?
unless /([0-9\.]+)% \(Combined\)/.match(options).nil?
combined = /([0-9\.]+)% \(Combined\)/.match(options)[1].to_f
end
unless /([0-9\.]+)% \(State\)/.match(options).nil?
state = /([0-9\.]+)% \(State\)/.match(options)[1].to_f
end
unless /([0-9\.]+)% \(County\)/.match(options).nil?
county = /([0-9\.]+)% \(County\)/.match(options)[1].to_f
end
unless /([0-9\.]+)% \(Special\)/.match(options).nil?
special = /([0-9\.]+)% \(Special\)/.match(options)[1].to_f
end
if combined==0 and state==0 and county==0 and special ==0 then
unless />([0-9\.]+)%</.match(options).nil?
combined = />([0-9\.]+)%</.match(options)[1].to_f
end
end
end
How should I refactor this code to remove repetition of each regular expression?