Is there a way to check how many paragraphs and sentences in Roblox TextBox?
Well you have some option. Sentences if they are all ended with a . Then you can split the string at the . And then get the length. For paragraphs if they are separated by new lines then, split it at the new line
Try it:
local text = [[Hello, this is
a test xd
yes, only a test
xd]] -- remplace it for Textbox.text
local amntofpar = 1
text:gsub("(%S)[^%S\n]*\n([%a()])", function()
amntofpar = amntofpar + 1
end)
print(amntofpar) -- It print how much Paragraphs are on it
This pattern matches:
-
(%S)- (captures into Group 1,%1) any non-whitespace character -
[^%S\n]*- matches (without capturing) zero or more chars other than non-whitespace and a newline (that is, it is the%spattern without\n) -
\n- a newline char -
([%a()])- (captures into Group 2,%2) any letter,(or)chars.
By default the text dont have %n at the start its why i start with 1 and no 0