String.split arguments question

I currently split a string with a separator of a space. How would I receive the arguments, if that’s what they’re called, in multiple?

For example, I only want it to return the words starting from 3+ words. For example, it should return from:
“Hello, my name is jack!”
to:
“is jack!”

Can this be done by using [3+]?

1 Like

I recommend to search for existing threads before making a new one, and you can also use gsub()

I have surfed a lot of the threads.

Expirement that, I recommend you use gsub tho.

I’ve looked at gsub, roblox puts it in the most confusing bundle of words I have ever seen.

I’ve figured it out after looking at the pattern, but I am unsure how this is useful for my inquiry.

local String = "Hello, my name is jack!"
local newstring = string.gsub(String, "Hello, my name ", "")
print(newstring) 

Yeah, that is the GSUB example right there.

you’re not splitting … your subbing… so use sub, not split …

Maybe use table.concat?

local split = string.split("Hello, my name is jack!", " ")
local wordsAfterTheThirdSplit = table.concat(split, " ", 3)
3 Likes

That as well works quite well.

That’s pretty cool, it’s a real bummer you miscounted :rofl:

local split = string.split("Hello, my name is jack!", " ")
local wordsAfterTheThirdSplit = table.concat(split, " ", 4)
print(wordsAfterTheThirdSplit)
local String = "Hello, my name is Jack!"
local Match = string.match(String, "^%S+%s%S+%s%S+%s(.+)")
print(Match) --is Jack!
2 Likes