To get all the strings between <actors>
and <actors>
, use string.gmatch
for global match:
for name in string.gmatch(fixstr, "<actors>(.-)<actors>") do
print(name)
end
Note the use of .-
in which -
matches zero or more occurrences, but it's non-greedy.
Output:
Hrithik Roshan,
Priyanka Chopra,
Actually, unless you need fixstr
for other uses, you don't need to substitute name:
and character:
to <actors>
, just one run of string.gmatch
can do the job:
for name in string.gmatch(str, "name:(.-)character:") do
print(name)
end