Craig
Craig

Reputation: 31

Remove Filename from string in Lua

I need cut off the .ogg from the end of a various strings

For example

v = bdorian.ogg
h = {}

h[1] = v

How could I cutoff '.ogg' from the end of string v?

(A quick google search yielded no help)

Upvotes: 0

Views: 2249

Answers (1)

Veer Singh
Veer Singh

Reputation: 963

Well, you can take everything before the last period

v = "bdorian.ogg"
h = {}
h[1] = v:match("(.+)%..+$")

Upvotes: 5

Related Questions