-1

How would a regex look like when i have the input

foo.bar/level/1A
foo.bar/level/1A/test
foo.bar/level/1B
foo.bar/level/1A/blabl/sdffs
foo.bar/test

As a result I only want the urls where the root items in the level folder so

foo.bar/level/1A

and

foo.bar/level/1B

So anything in the level folder that is nog followed by a slash basicly What is the best regex way to extract these ?

Thx (I realy need to find a good regex training cause I always bump into this stuff when there is look ahead / back and stuff involved)

blhsing
  • 91,368
  • 6
  • 71
  • 106
byenary
  • 301
  • 2
  • 3
  • 7

1 Answers1

1

You can use:

^[^\/]*\/level\/[^\/]*$

Demo: https://regex101.com/r/iqnsjV/1

blhsing
  • 91,368
  • 6
  • 71
  • 106