I would like to validate a URL path to make sure it doesn't include things like back-to-back ?
's, &
's, =
's or -
's. The path should only include a-z, A-Z, 0-9, ?, -, &, and =.
For for example, these should pass:
item/643fe4ac-e87d-4b71-8fd1-522154f933c2/okay
person/adam?height=23&favcolor=blue
city/building/916fe4ac-e87d-4b71-8fd1-522154f933r5
While these should fail:
item/643fe4ac--e87d-4b71-8fd1---522154f933c2/okay
person/adam??height=23&favcolor=blue
city/@/916fe4ac-e87d-4b71-8fd1-522154f933r5
Solutions I've looked at online don't seem to work when I try them out on https://regexr.com/ (for example, this) or they are built for a non-dynamic url path or for specific situations (i.e. this or this).
I've tried building one from scratch, but I'm very inexperienced with Regex, so I managed to get a starting point of [a-zA-Z0-9/]*
which basically matches anything except spaces, but needs A LOT of work to get to what I want.