This feels like a silly question, but I have a string like:
aaaa/bbb\/ccc
The \/
represents an escaped delimiter being used in the name of a path component.
So, the string represents two path components aaaa
and bbb/ccc
This string is generated based on a need to create a path from path components where the need is to use / as the delimiter between components and / may also appear in a component name. This is the reason behind the need to escape / when it appears in a component name.
There may be two or more components.
Using a regex like (?:\\\/|[^\/])+
is close to what I am looking for, but when considering the string this/is\/a/\/str\\/ing
, it fails to split it into the components this
& is\/a
& \/str\\
& ing
.
Instead, the final component is determined to be \/str\\/ing
.
My question is what does the javascript code look like that would allow me to split paths into path components when the component delimiter can be used in the name of a component?
In the example above, I would want to end up with two strings aaaa
and bbb/ccc
?
Is there a standard function that deals with this or would I need to use a regex to help me split?
Thank you.