Jump to content

[TUT] Lua Strings


Recommended Posts

Thank you dude that's what exactly i wanted :D
Great job, also add string.count and string.explode usefull functions contributed by Mta users.

These "useful functions" are rather useless now, as for they can both be done with MTAs default split function

You're doing well , sir Walid good job .

Thx guys.

Link to comment
Another good tutorial by you, good job!
Good Job :]

Thx Guys hope it helps.

I found a mistake in

5. Formatting string

-- Date Format

local date = 3

local month = 2

loal year = 2020

outputChatBox(string.format("Date %02d/%02d/%03d", date, month, year)) -- Result: Date 03/02/2020

'C' fixed, thx .

Link to comment
  • 2 weeks later...

A good addition to this tutorial would be to teach people how to manipulate strings using regular expressions.

For example, this can be used to find a URL. This is very useful in case you need to download XHTML files from a website and read through it in order to find a URL.

local string1 = "https://forum.multitheftauto.com/posting.php?mode=reply&f=148&t=88427" 
local findURL = string.match(string1, "http?://[%w-_%.%?%.%+=&]+") 
print(findURL) -- Prints "https://forum.multitheftauto.com/posting.php?mode=reply&f=148&t=88427" 

Link to comment
  • 6 months later...
  • 2 months later...
  • Recently Browsing   0 members

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