How Can I Pick Text Out Of A String?

So, I really need this. I want to be able to pick some text out of a string and make it a variable. Here’s a demonstration;

local string = [[
Application Creator: Aiden_12114
Application Results: 5/10
]]

local Result = string.take(string, 'Application Results: %')
local Creator = string.take(string, 'Application Creator: %')

How can I do this?

local appCreator = string.gsub("Application Creator: Aiden_12114", "Application Creator: ", "")

Would you mind explaining it?

That just remove that bit of the text, it doesn’t grab it. You’d want a string pattern here; something that captures the relevant bit:
local whatever = yourString:match("Application Results: (%S+)").
The “%S” tells it to look for non-whitespace characters, the “+” tells it to look for multiple of those characters, and the parentheses tell it to capture just that bit.

More info can be found on the wiki:
https://developer.roblox.com/en-us/articles/string-patterns-reference
https://developer.roblox.com/en-us/api-reference/lua-docs/string

6 Likes

how so?

Did you misread the string in his original post? It’s formatted more complexly, and your pattern removes part of the string rather than parsing it.

2 Likes

yup just tested your solution is perfect and way better

1 Like