I'm trying to parse string into 5 parts. For example:
var str1 = '#<SYSTEM list-of / asdf-finalizers-20140826-git / quicklisp 2014-08-26>'
// filter is used to remove empty strings from the returned array
str1.split(/[ #<>/]/).filter(function(n) { return n !== ''; });
// str1[0] -> SYSTEM
// str1[1] -> list-of
// str1[2] -> asdf-finalizers-20140826-git
// str2[3] -> quicklisp
// str2[3] -> 2014-08-26
But the problem is, I can't parse the strings containing slash in the middle of words For example,
#<SYSTEM asdf-finalizers-test/1 / asdf-finalizers-20140826-git / quicklisp 2014-08-26>
What is the correct regex to parse the word asdf-finalizers-test/1? I tried these but failed.
/[(\s\/\s) #<>]/, /[(?:\s\/\s) #<>]/, /[ #<>]|(\s\/\s)/
/[ #<>]| \/ ]/. Your filter can also be written asfilter(Boolean).filter(Boolean)is so handy. But/[ #<>]| \/ ]/doesn't work. I'm usingnode.js 0.10.31It is because ofnodejs?/ \/ |[ #<>]/. Works in both browser and node. The problem is that if the ` / ` option is placed second, it matches on the space first before it gets to the second option, and you end up with slashes in your output.