Jump to content

String bontás


Recommended Posts

local example = "an example string"
for i in string.gmatch(example, "%S+") do
   print(i)
end

-- output:
-- an
-- example
-- string

Annyi a dolgod, hogy a gmatch stringjét átírod. Szerintem ha a gmatch-nek "-"-t adsz meg értéknek, akkor jól fogja felbontani. Aztán tömmbe rakod.

Link to post

Talán itt van egy egyszerűbb megoldás (számomra biztosan egyszerűbb):

local datumString = "2020-02-10"

local datumArray = split(datumString, "-")

print(datumArray[1], datumArray[2], datumArray[3]) 


 

Link to post

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...