If I have a file path such as:
var/www/parent/folder
How would I go about removing the last folder to return:
var/www/parent
The folders could have any names, I'm quite happy using regex.
Thanks in advance.
This is no specialized version of split
per se, but you can split by the path.sep
like so:
import path from 'path';
filePath.split(path.sep);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With