Frage

I would like to use string.gsub to search through a phone number field and remove any "-" or spaces.

Is there any way to combine the two statements I have below into one?

local phonenumber = string.gsub("123-123-1234", "-", "")
phonenumber = string.gsub(phonenumber , " ", "")
War es hilfreich?

Lösung

Yes. The square brackets are used to group multiple elements in Lua patterns

local phonenumber = string.gsub("123-123 -1234", "[- ]", "")
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top