Consider this URL for example:
domain.com/search.action?zip=94558&year_max=2018
I am trying to build a regex that captures domain if URL satisfies either of these 2 conditions
- The URL doesn't have a
year_maxparameter. - The URL does have a
year_maxparameter and it takes one of these values (2019,2020,2021,2022) for year.
Update: The urls can have multiple & and could have other parameters after year_max. The only certainty is that year_max paramter is the last one that needs matching (if it exists) and all other parameters would have their capture groups defined before it.
Here is my attempt so far:
(domain\.com)\/.*(?:&year_max=2019|2020|2021|2022)?
How do I modify it so that if I have a set of URLs like below, it only matches on the first and the 3rd URL?
domain.com/search.action?zip=94558&year_max=2020
domain.com/search.action?zip=94558&year_max=2017
domain.com/search.action?zip=94558