0

I was wondering if there's a way to actually separate "choices" that are separated by a symbol, from a string to a table?

So after a lot of trials, the closest I could get is with this code:

local Test = string.gsub("butterscotch; fried rice; iced bubble tea; e; human, medium rare; お前の終焉", ";%s*", ";")
local Choices = {}

for Choice in Test:gmatch("%a*[^;]") do
    table.insert(Choices, Choice)
end

for i, v in pairs(Choices) do
    print(i, v)
end

Which yields to:

1   butterscotch
2   fried 
3   rice
4   iced 
5   bubble 
6   tea
7   e
8   human,
9    
10  medium 
11  rare
12  �
13  �
14  �
15  �
16  �
17  �
18  �
19  �
20  �
21  �
22  �
23  �
24  �
25  �
26  �

When the result I wanted is supposed to be:

1   butterscotch
2   fried rice
3   iced bubble tea
4   e
5   human, medium rare
6   お前の終焉

Is there any way to tackle this problem? :') I appreciate it if someone can help me since I've been stuck for some time and I couldn't figure out the solution...

Thank you in advance! ^^"

JustHowWhy
  • 13
  • 4

0 Answers0