Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I store a specific part of a string after finding it?

Asked by
Pojoto 329 Moderation Voter
5 years ago

For example, if the string was "Hello World", would I be able to search the string for the letter "e" and then store that "e" as a string on its own?

0
string.sub User#19524 175 — 5y
0
string.find might be of help to you. User#21908 42 — 5y
0
actually string.match but that can work User#19524 175 — 5y
0
string.find would get the location User#21908 42 — 5y
View all comments (3 more)
0
yeah User#19524 175 — 5y
0
I know, but I don't want it to return a location, I want it to return the single letter it found. I'll try match and sub, though not too familiar with them now. Pojoto 329 — 5y
0
string.match("Hello World", "e") will give you the location, then you can use the location with string.sub to get the lone letter as a value. After that, you can just store the lone letter into a variable. iiOmqLeetHyackth101 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

let's say the string is "hello world" to store it, you can use this method

local StoreString = Instance.new("String Value")
StoreString.Name = "Store String" -- just an example
StoreString.Parent = workspace -- just an example
StoreString.Value = "Hello World"
0
not what op wanted + you know how to use code blocks so use them User#19524 175 — 5y
0
I just put them in blocks FirezoneGamez 155 — 5y
Ad

Answer this question