the usual workaround is to use match
instead of split
:
> s = "name\\|dial_num|032\\|0095\\\\|\\\\0099|\\9925"
"name\|dial_num|032\|0095\\|\\0099|\9925"
> s.match(/(\\.|[^|])+/g)
["name\|dial_num", "032\|0095\\", "\\0099", "\9925"]
As a side note, even if JS did support lookbehinds, it won't be a solution, because (?<!\\)|
would also incorrectly skip \\|
.