With a negative lookahead, or with a negated class.
Negated class:
^/path/[^/]*$
A negated class will match everything except what's inside, in this case, a forward slash and the anchor $
at the end ensures that the string is tested till the end.
Negative lookahead:
^/path/(?!.*/)
A negative lookahead will make the whole match fail if what's inside matches. So, if .*/
matches at the point of the negative lookahead, the match will fail.
Note: I usually use delimiters that uses characters not appearing in my regex. In this case, I change the delimiters from /
to ~
.