How to filter everything after a word using regex

This article was published on May 08, 2021, and takes less than a minute to read.

Given the follow string:

/home/raulmelo/development/raulmelo-studio/node_modules/esbuild/lib/main.js

I wanted to remove EVERYTHING right after the world esbuild.

I could go with replace('/lib/main.js', '') but this is not future proof. What if in the future it changes to /lib/index.js?

So I came up with a regex to do that:

Internal server error