re = /\?((?:(?<rid>regionId)=(?<ridv>[\d\$,_]+)|(?<sid>sectionId)=(?<sidv>(?P>ridv))|(?<a>age)=(?<av>(?P>ridv))|(?<p>purpose)=(?<pv>(?P>ridv))|(?<l>lineId)=(?<lv>(?P>ridv))|(?<stid>stationId)=(?<stidv>(?P>ridv))|(?<pe>price)=(?<pev>(?P>ridv)))&?)+/m
str = 'https://market.591.com.tw/?age=_5,10_20&purpose=4§ionId=9&price=70_80,_50'
# Print the match result
str.match(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html