Code: Select all
str = "(1, 'test', none, 10, '', , 'hi, this is a default bio. change it (asap)!')"
for inf = 1, 9 do
pat = "%(" .. string.rep("%s?'?.-'?[,%)]+", inf - 1) .. "%s?'?(.-)'?[,%)]+"
result = str:match(pat)
print(result, "#" .. inf)
end
--Print result must be:
--1
--test
--none
--10
--
-- or nil
--hi, this is a default bio. change it (asap)!
--nil
--nil
1 #1
test #2
none #3
10 #4
#5
#6
hi #7
this is a default bio. change it (asap #8
! #9
I can't find a solution that if found a starting "'", ignores all rules until find a closing "'" and match a right pattern (a ", " or ")$")