I need to split a string similar to a path, which is delimited by dots. The tricky part is that the each subentry may also contain dots, which are escaped by another dot. Each entry may otherwise contain basically anything (including special characters such as space or :;/\|(), etc..)
Two examples:
"Root.Subpath.last/entry:with special;chars" -> [0] Root [1] SubPath [2] last/entry:with special;chars
"Root.Subpath..with..dots.Username" -> [0] Root [1] SubPath.with.dots [2] Username
Currently I am not using a regular expression for this, instead I am replacing any ".." with something else before running a split, and adding them back after the split. This works fine and everything, but its not super clean. However, mostly I am curious (or maybe annoyed about?) how to create a Regex for Regex.Split
that does the same thing, as this was my first idea of approach. I provide my current solution to show what output I expect.
Split(path.Replace("..", REP_STR), ".") _
.Select(Function(s as string) s.Replace(REP_STR, ".")).ToArray
I am using VB.NET.