'Testing for exact string with Regexp

I'm trying to find the exact match for the following strings;

/test/anyAlphaNumericId123
/test/anyAlphaNumericId123/

That will not match the following

/test/anyAlphaNumericId123/x

I have the following Regex currently, which matches both former cases and not the latter;

/(\/test\/)(.*?)(\/|$)/

But on attempting to call str.match on it, I will also get a result for the latter, as it has a partial match. Can I accomplish this with Regex alone?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source