-3

I have the following regex:

(?<=unit/)(.*)(?=/)

I use it to get a page name between unit and the guid.

www.page.com/module/unit/design/6e8c1d2b-34vc-4b5c-71af-8b0f93b01b60?sid=5fh6y172-31d9-4r6b-9a15-daed6c541162&culture=en-US

Now i am receiving an URL like this, with /load before the sid.

www.page.com/module/unit/design/6e8c1d2b-34vc-4b5c-71af-8b0f93b01b60/load?sid=5fh6y172-31d9-4r6b-9a15-daed6c541162&culture=en-US

so i am getting this result from the regex

design/6e8c1d2b-34vc-4b5c-71af-8b0f93b01b60

How can i change the regex in order to get just design, moreover how can i create a regex that find design either or both URLs?

Barmar
  • 741,623
  • 53
  • 500
  • 612
Andres
  • 29
  • 3

1 Answers1

0

Instead of .* use [^/]* to match any sequence of characters not including /. This will get everything until the next /.

(?<=unit/)[^/]*
Barmar
  • 741,623
  • 53
  • 500
  • 612