Path matching greater than > and lesser than < symbols
I am trying to match greater than > and lesser than < symbols in the path of Express 4.17.1, but it is not working. I tried regex match using /[><]/, but it is not matching a path with /test/.
Is there any special handling that we need to do to handle this like how it is for $ where we use ([$])? Any help here is appreciated.
A regex is just a regex, but why would [<>] match /test/?
A regex is just a regex, but why would
[<>]match/test/?
Sorry that was a typo, it was not matching a path with /test/
That's correct though. There are no characters of >< in /test/.
That's correct though. There are no characters of
><in/test/.
I think whatever I am writing is not getting shown (I have added in quotes now sorry :() what I meant was Sorry that was a typo, it was not matching a path with /test/<param>
I tried couple of other things too, /(><)/ , /.(><)./, and /.[><]./ but none of these regex are matching this path /test/<param>
There's probably two issues you're having:
/[><]/matches because it's a regex, the others you wrote don't make sense. You can test a regex like usual, e.g./[><]/.exec('/test/<param>').- If you're trying to match this coming from a URL path,
<and>are not valid characters and would be URL escaped so matching on<and>is impossible to do, you'd want the URL encoded versions instead
Got it, Thanks @blakeembrey. /(%3E|%3C)/ works.