Friday, November 4, 2022

Pattern for a route without slash at the end (regex)

 Hi guys! I want to share with you a regex to use as a patter for entering a route:

valid:

/something123

/something/somethingelse/thiselse

not valid:

/*-*-*-*-

/something/*=*-=

/something123/

The regex is:

/^(?:\/(?:[a-zA-Z0-9])+)+$/

Happy coding!