Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Do someone know how to detect if a newline is in a string via scripting?

if u know let me know please I was searching that all the day and I had no result, Thank you!

2 comments

0

I tried

0

then show your attempts

1 answer

✓ Accepted answer

I don't really mind if you have don't any code to provide of your attempt but I'm gonna help anyway. I'm gonna explain most things here aswell.

Alright, so first of all when you speak of newline you are referencing to "\n" which means in other words. A new line, so how are we going to incorporate it into how you want it? We are going to be using string.gmatch basically how you use string.gmatch is basically the same as iterating through GetChildren().

Essentially what I'm talking about is the method is similar to:

for i,v in pairs({35,35,35,53}) do
	print(v)
end

So here is how we are going to incorporate it into our code:

for line in string.gmatch(String, "[^\n^]+") do
	print("A new line has been detected!")
end

I can't go into much detail with the [^ ^]+ part since I don't tangle with string patterns all the time.

If you have any questions let me know.

This discussion is preserved as it was. New answers, comments, and votes are closed.