I have 2 strings:
"test:header_footer"
"test_3142"
I want to get array:
array = "test:header_footer".split(":") // ['test', 'header_footer']
array2 = "test_3142".split("_") // ['test', '3142']
Can I combine this with a regex expression to get the same result?
function(s) {
retutn s.split(/:|_/) // return bad value
}
So if string contain ':' - not separate by second '_'
:is present, and then choose the split character accordingly.:and_, how do you decide which one is the delimiter?