The regex should match
/exampleline – match exampleline
exampleline – match exampleline
exampleline/ – match exampleline
/exampleline/ – match exampleline
I tried ?/(.+)/? but it didn’t work – /exampleline/ and exampleline/ matched exampleline/, instead of exampleline
>Solution :
You can use negative lookarounds to assert that a match does not start with and does not end with a /:
(?!/).+(?<!/)
Demo: https://regex101.com/r/EKOvzG/2