I’m having trouble with a matching expression. I want to extract the "code" parameter from a link I extracted using Nokogiri, so I tried:
event_id = a.attr("href").match(/\?code=(\d+)/)[1]
Unfortunately what is extracted is the entire query string:
?code=768140119
What is the proper way to just get the value of the parameter and nothing else?
a.attr("href")[/\?code=(\d+)/, 1]? Or justa.attr("href")[/\d+/](if there is only 1 sequence of one or more digits)?a["href"][/\d+/][1]of the match?