I have string as below
This | is a sample \| string
I would like to split the above string based on | and do not split where | is escaped. (\|).
Note: I have come up with the below regular expression.
You could perform a match instead of a split:
> 'This | is a sample \\| string'.match(/([^\\|]|\\\|?)+/g) ["This ", " is a sample \| string"]
The above matches: