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

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

Asked by 6 years ago

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

0
I tried Xx_XSanderPlayXx 160 — 6y
0
then show your attempts User#23365 30 — 6y

Closed as Too Broad by User#19524

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?

1 answer

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

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.

Ad