I want to split string for ">" but not when >> in JavaScript.
But once I am doing a split const words = str.split('>'); it is splitting >> as well.
Currently, after the split I look for "> >" and then substitute them with ">>".
How to implement it properly.
You can use a regular expression leveraging:
The resulting pattern would be as follows:
/(?<!>)>(?!>)/
Using the patter to tokenize an input would lead the desired results:
"here>>I>am".split(/(?<!>)>(?!>)/) // => [ 'here>>I', 'am' ]