Vim has start and end anchors (
\ze respectively) that you can use. In this case, the
\ze anchor will help match what you're looking for:
foo\ze\/ matches the "foo" in "foo/bar/baz"
In this example, it stops the search the match after it finds "foo" followed by a "/" but does not include the "/" since we put the anchor before it.
You can read the help on the
\ze anchor for more information:
\ze Matches at any position, and sets the end of the match there: The
previous char is the last char of the whole match. |/zero-width|
Can be used multiple times, the last one encountered in a matching
branch is used.
Example: "end\ze\(if\|for\)" matches the "end" in "endif" and "endfor".
This cannot be followed by a multi. |E888|