0

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)

1 Answer 1

5

Well, you can take everything before the last period

v = "bdorian.ogg"
h = {}
h[1] = v:match("(.+)%..+$")
Sign up to request clarification or add additional context in comments.

1 Comment

This match does not return filename if there's no an extension! In that case it returns nil.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.