So I take it that what you’re attempting to do is separate sets of weaponry through those horizontal lines? For example, when you save it the string looks like what you posted but when you want to update values for a weapon, you want to split them each up? Visual aid to what I mean:
Saved string:
"|Katana: 15,1000,1||Pistol: 2,0,3|"
Wish to split like so:
"|Katana: 15,1000,1|"
"|Pistol: 2,0,3|"
If the above is the case where you want to attempt to interact with items of the string in the basis of two horizontal lines, you are actually going to want to use gmatch, not match. You will also require a for loop to iterate over all matched cases.
local a = "|Katana: 15,1000,1||Pistol: 2,0,3|"
-- Also acceptable: string.gmatch(a, "%b||")
for weaponData in a:gmatch("%b||") do
print(weaponData)
end
The following code will result in this output:
|Katana: 15,1000,1|
|Pistol: 2,0,3|
gmatch is meant to be a pattern iterator, so what we’re basically doing is taking match and instead turning it into something we can iterate over. The %b|| is a balanced capture which will match everything between the lines as well as the lines themselves. Then, we can retrieve each match of our pattern (any string that appears as |inner text|) and handle that accordingly.
Does this answer your question?