I’m attempting to remove something from a string using regex that matches substrings before /../ that either begin at the start or follow a / .
So far I have
re.sub('(?<=[/]|\A).+(?=[/][.][.][/])', '', str)
I keep getting errors though when I attempt this or other variations ranging from it deleting all items after the first / to not deleting the first character of the grouping.
It appears that
/itself can never be part of the match. Therefore, try[^/]matches any character that isn’t a/, so it starts matching at the start of the string until it encounters/../, unless there’s a/in-between, in which case the match will start after that.