I have a period and backslash escaped string. I would like to split the string using any unescaped periods, but am struggling to come up with a pattern to do so.
const escaped = "two slashes: \\\\.one period: \..line and a dot: \\\.";
// ["two slashes: \\", "one period: .", "line and a dot: \."]
console.log(escaped.split(/* ? */))
This (?<!\\)(?:(\\\\)*)[*]
is close, but split()
includes capturing groups in the ouput array, which is not what I would like. The solution should be match-only, like here:
(?<!\\)(?:\\\\)*\K\.