MTS_LoneWolf Posted December 7, 2022 Share Posted December 7, 2022 (edited) eu não majo muito de formatar strings e queria saber como transformar 4154827353 em (415)482-7353 OBS: serão sempre 10 digitos Edited December 7, 2022 by MTS_LoneWolf Link to comment
Other Languages Moderators Lord Henry Posted December 7, 2022 Other Languages Moderators Share Posted December 7, 2022 (edited) function stringToPhone (str) local ddd = "("..string.sub(str, 0, 2)..")" local a = string.sub(str, 3, 6).."-" local b = string.sub(str, 7, 10) return ddd..a..b end print (stringToPhone(1140028922)) -- Vai printar isso: (11)4002-8922 Edited December 7, 2022 by Lord Henry 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now