generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: String matching on a multiline string

Previous Thread :: Next Thread 
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
23 Sep 2013 04:44 PM
Is there a way to get string.gmatch to return every line of a multiline string? I'm not good with regular expressions, but this is what I came up with.

String = [[
Hello
There
:)
]]

for Capture,_ in String:gmatch(".+\n") do
print(tick(),Capture)
end

-- tickvalue Hello
There
:)
--

It just prints the entire thing, not line by line.
Report Abuse
Rhinocrash is not online. Rhinocrash
Joined: 26 Sep 2010
Total Posts: 106
23 Sep 2013 04:47 PM
I think you need to use a table.
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
23 Sep 2013 05:22 PM
Bump.
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
23 Sep 2013 05:27 PM
"." is any character so \n fulfills this requirement.

String = [[
Hello
There
:)
]]

for Capture,_ in String:gmatch("[^\n]+") do
print(tick(),Capture)
end
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
23 Sep 2013 05:31 PM
Thank you so much!
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
23 Sep 2013 05:33 PM
Glad to help :P
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image