Now that we've cleared up what the question is about, here's the
gmatch pattern will return all of the matching
substrings in the given string. However, your
uses "+". That means "one or more", which therefore cannot match
an empty string. If it encounters a
^ character, it just skips
But, if you just tried
:gmatch("[^^]*"), which allows empty
matches, the problem is that it would effectively turn every
character into an empty match. Which is not what you want.
What you want is to eat the
^ at the end of a substring.
But, if you try
:gmatch("([^^])^"), you'll find that it won't
return the last string. That's because the last string doesn't end with
^, so it isn't a valid match.
The closest you can get with
gmatch is this pattern:
"([^^]*)^?". This has the downside of putting an empty string
at the end. However, you can just remove that easily enough, since one will
always be placed there.