Jump to content

Parsing lines


[TC]Trek

Recommended Posts

Posted

Hello,

i would like to explode string into lines but i dont know how to do it.

there is an example what i want

  
function exampleFunction(someString) 
     firstLine = getFirstLine(someString) 
     secondLine = getSecondLine(someString) 
     outputChatBox("Parsed string:") 
     outputChatBox("- Line 1: "..firstLine) -- should print "Abcde_at_1_line" 
     outputChatBox("- Line 2: "..secondLine) -- should print "StartOfSecondLine" 
end 
  
exampleFunction("Abcde_at_1_line\nStartOfSecondLine") 
  

can anyone help me please? :)

Posted
split 

function exampleFunction(someString) 
 outputChatBox("Parsed string:") 
  s = split(someString,"\n") 
   for i,v in ipairs(s) do 
    outputChatBox("- Line "..i..": "..v) 
    end 
 end     
exampleFunction("1\n2\n3\n4") 

tested it

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...