I can't find solution how to extract specific part of a path when I have a glob pattern for it.
I have incoming file paths that look like this:
'src/features/gui/images/main/effects/lightning/1.png'
And I want to extract specific leading part of it (always beginning of a path):
'src/features/gui/images/main/'
And I have two incoming glob patterns (the patterns may change, but will always point to a directories and images inside them):
'src/features/*/images/*/'
'src/features/*/images/*/**/*.{png,jpg,gif}'
I would like to extract directory path that matches pattern #1 in incoming file paths.
My intuition tells me it should be trivial, but can't find a solution. I'm looking in a solution that operates only on strings (or regexp) and do not do additional glob searches on disk. I've searched various JS modules on NPM, but all what I've found only returns if path matches glob pattern, but not actual match substring.