I am new to node.js, and programming in general. I am currently experimenting with regular expression in javascript & node.js. I thought maybe people could help me out a little, but if this is the wrong sub, please apologise and I will see if there is something more appropriate.Right now my regular expression go through the string and splits it by occurences of `/`, keeping the slash in the array.var str = 'File/path/to/a/file.js';let delim = /[^\/]+\/?|\//g;var tokens = str.match(delim);// ["File/","path/","to/","a/","file.js"]As an exercise, I would like to also split by `.`, `?` and `!`. How could I accomplish this without making things too messy? I'm a beginner, so I would ideally like to not have one massive regular expression string. Ideally, I would create an array of regular expressions (with each element of the array handling one delimiter). I have tried to do this but failed.
Submitted July 02, 2018 at 02:00PM by jupytermars
No comments:
Post a Comment