Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help,
read this .
Darlex
Party member
Posts: 128 Joined: Sun Sep 24, 2017 10:02 am
Location: Chile
Contact:
Post
by Darlex » Sun May 12, 2019 8:50 pm
Something like:
Code: Select all
input = [[
Im a cool dude
doesnt it?
]]
table = divide(input)
printtable(table)
OUTPUT:
{"Im a cool dude","doesnt it?"}
Last edited by
Darlex on Sun May 12, 2019 11:10 pm, edited 1 time in total.
Hi! I wish you have an amazing day!
raidho36
Party member
Posts: 2063 Joined: Mon Jun 17, 2013 12:00 pm
Post
by raidho36 » Sun May 12, 2019 10:09 pm
Code: Select all
for line in string.gmatch ( str, "(.-)[\n\r]" ) do ...
Darlex
Party member
Posts: 128 Joined: Sun Sep 24, 2017 10:02 am
Location: Chile
Contact:
Post
by Darlex » Sun May 12, 2019 11:05 pm
raidho36 wrote: ↑ Sun May 12, 2019 10:09 pm
Code: Select all
for line in string.gmatch ( str, "(.-)[\n\r]" ) do ...
That's useful! THX
Hi! I wish you have an amazing day!
raidho36
Party member
Posts: 2063 Joined: Mon Jun 17, 2013 12:00 pm
Post
by raidho36 » Sun May 12, 2019 11:14 pm
You can use the following pattern if you want to ignore blank lines:
Also I've noticed that the previous pattern requires a newline at the end of the string. Good thing it's a common practice to end all text files with a newline, most editors do this automatically.
Users browsing this forum: Ahrefs [Bot] and 86 guests