I have a string that need to be split with a regular expression for applying some modifications.
eg:
const str = \"Hello+Beautiful#World\";
const spl
You could get the missing substrings by iterating the splitted value and check the parts.
var string = "Hello++#+Beautiful#World",
splitted = string.split(/[\+#]+/),
start = 0,
symbols = splitted.map((s, i, { [i + 1]: next }) => {
var index = string.indexOf(next, start += s.length);
if (index !== -1) {
var sub = string.slice(start, index);
start = index;
return sub;
}
return '';
});
console.log(symbols);
console.log(splitted.map((s, i) => s + symbols[i]).join(''));