How would I convert this into a lua table?

Hi guys, could someone who’s experienced with string patterns help me convert these into a table array of strings? Thanks!

e.g. becomes…

local array = {
	"Aaren",
	"Aarika",
	"Abagael",
	"Abagail",
	"Abbe",
	"Abbey",
	"Abbi",
	"Abbie",
	"Abby",
	"Abbye",
	"Abigael",
	"etc"
}

I believe you can use the find/replace tool combined with string patterns in studio to automatically achieve this:
image

1 Like

Not sure if you actually can but I haven’t used the find/replace thing too much to know
BUT you could probably just set the string as a variable (or require it from a modulescript) and then use string.split to put it into an array
something like this:

local NameString = [[test1
test2]] --put names here

local tbl = NameString:split("\n")

print(tbl)
local HttpService = game:GetService("HttpService")
local function GetAsync(Url)
	local bool, Info = pcall(HttpService.GetAsync, HttpService, Url)
	if not bool then
		warn(Info)
	end
	return bool and Info
end

local Names = GetAsync("https://raw.githubusercontent.com/dominictarr/random-name/master/first-names.txt")
local ArrayOfNames = {}
if Names then
	ArrayOfNames = Names:split("\n")
end

print(ArrayOfNames)
3 Likes

You should be able to replace \n with , though I’m not versed in Studio’s find and replace. It’s fairly straightforward in most decent editors like Sublime Text or Visual Studio Code, however.