user10236002
user10236002

Reputation: 1

Ignore One Part of URL and Match Rest

I'm new to RegEx and am sure this is an easy one. I looked at similar questions, but being new to RegEx, how it all fits together it still fuzzy.

I want my RegEx to:

  1. ignore a single parameter in my URL and match anything that pops up in the first two parameters (/purple/cat/)
  2. match the specific word (/prices)in the last part of the URL
  3. BUT not match the date in the middle/ignore that part (and any other date)

URL string:

/purple/cat/2017/prices

RegEx:

\/.*\/.*(?<!(20[0-17])\/prices$

Upvotes: 0

Views: 304

Answers (1)

MandyShaw
MandyShaw

Reputation: 1156

How about this - it matches anything with /purple/cat/ + any 4-digit number + /prices:

\/purple\/cat\/[0-9][0-9][0-9][0-9]\/prices

P.S. https://regexr.com/ is useful for playing with regex's.

Upvotes: 1

Related Questions