I need to match data within a string in order to parse the data. The format for the data is follows
A*(anything)B*(anything)ABC*(anything)
The keys will always be A, B, ABC or DCE.
I have it working for the keys with the length of one character.
$(function() {
var s = "A*(anything)B*(anything)ABC*(anything)DCE*(anything)";
s.match(/(A|B|ABC|DCE)\*[^*]+(?!\*)/g).forEach(match => {
var [k, v] = match.split('*');
console.log(k + "->" + v);
});
});
However, this is the output (doesn't work with 1+ length keys
A->(anything)
B->(anything)AB
DCE->(anything)
The value is not always (anything) - it is dynamic.
I think the issue is with (?!*)/g