I would like to match all characters in a string except for the #*# pattern. The regex I have below works for cases such as match1 below, but it will also match #'s or 's that are not in the ## pattern as seen in match2 below and fail because of that. How can I fix the below regex to match #*# if they appear together?
var string1 = 'Hello#*#World#*#Some other string#*#false'
var string2 = 'Hello#*#World#*#Some #other #string#*#false'
// This would match
var match1 = string1.match(/^([^#*#]+)#\*#([^#*#]+)#\*#([^#*#]+)#\*#([^#*#]+)$/);
// This would no longer match since it matches other #'s that are not in a #*# pattern
var match2 = string2.match(/^([^#*#]+)#\*#([^#*#]+)#\*#([^#*#]+)#\*#([^#*#]+)$/);
Also the match should match the whole words between the pattern. So for match1 it would be
[ 'Hello#*#World#*#Some other string#*#false',
'Hello',
'World',
'Some other string',
'false',
index: 0,
input: 'Hello#*#World#*#Some other string#*#false',
groups: undefined ]