I have a URL that can contain any combination of parameters used in filtering results. The two params are type and sort. If type exists in the URL, it has to be either 'article', 'opinion', 'review', or 'media. If sort exists in the URL, it has to be one of the following: date-desc, date-asc, views-desc, views-asc, comments-desc, comments-asc.
Right now, the expression I have only matches URI's with both type and sort. And it doesn't match URL's that contain neither params. I would like the expression to match URL's without any parameters and URL's that have only one parameter. It also has to start with either nintendo, pc, playstation, or xbox.
Here are my example strings:
xbox/type:article/sort:date-desc (match)
nintendo/type:media/sort:comments-asc (match)
pc/sort:views-desc (no match)
playstation/type:opinion/ (no match)
playstation/sort:views-asc (no match)
xbox/sort:views-asc/type:article (no match)
playstation/type:media/sort:views-asc (match)
xbox (no match)
All of the above combinations need to match. Here is my current expression:
(nintendo|pc|playstation|xbox)[\/]((type\:(article|opinion|reivew|media))[\/](sort\:(date-desc|date-asc|views-desc|views-asc|comments-desc|comments-asc)))
Here is the Regex101 link: http://regex101.com/r/eN0tJ5