How to split a string on delimiter except when delimiter is inside the slashes?

Friends, Hello! Given a string:

str = 'numeric|min:5|regex:/abc|bca\//|max:10'

through str.split(/regexp/) you want to split on the | character, except in those cases where the symbol is located inside the slashes / /:

['numeric', 'min:5', 'regex:/abc|bca\//', 'max:10']


I have a few hours - I hope for your help. Thank you!
July 8th 19 at 12:10
1 answer
July 8th 19 at 12:12
Score!!!! do greedy
js d8e944a24bfe40a395315c605ccc9d45.png
php ccc78bcbee054b36871e8c95f1876906.png
pt 2aae0e57f4a645879fb86232a112ccbb.png
well done! only I understand that the js for this solution not suitable? - Drew1 commented on July 8th 19 at 12:15
A little work with js... and js unless other standards regexps ? Something I somnivayus. Yes the flags are different but there are General baseline used. Check mark this possible. - Pinkie_Rogah commented on July 8th 19 at 12:18
: trite, if you choose to regex101.com flavor as javascript - it is evident that the regular season doesn't work :( - Drew1 commented on July 8th 19 at 12:21
Now have a look thanks for the advice - Pinkie_Rogah commented on July 8th 19 at 12:24
As you can see, the posix standards are the same although in js like perl compatible regular season - Pinkie_Rogah commented on July 8th 19 at 12:27

Find more questions by tags Regular expressions