I have come across these variations of strings:
some/dir/with/end/slash/
/some/dir/with/start/slash
some/dir/without/any/start/or/end/slash
/some/dir/with/both/slashes/
My goal is to remove both the start and end slashes if they exist, while keeping the middle ones intact, all in a single operation.
Is there a way to achieve this in one go?
I am currently utilizing NodeJS along with TypeScript for this task.
The expected output should be:
some/dir/with/end/slash
some/dir/with/start/slash
some/dir/without/any/start/or/end/slash
some/dir/with/both/slashes