ozulus Posted September 18, 2015 Share Posted September 18, 2015 Hi guys i have a problem about string. For example i have a word which called "Furkan Ozulus" I want to convert letters to underline like that "_ _ _ _ _ _ _ _ _ _ _ _" Thanks. Link to comment
Moderators IIYAMA Posted September 18, 2015 Moderators Share Posted September 18, 2015 All characters included spaces? Link to comment
Moderators IIYAMA Posted September 18, 2015 Moderators Share Posted September 18, 2015 local testString = "Furkan Ozulus" local newString = string.rep("_",string.len(testString )) outputChatBox(newString) Or: local newString = string.rep("_ ",string.len(testString )) outputChatBox(newString) Link to comment
ozulus Posted September 18, 2015 Author Share Posted September 18, 2015 Thanks for your quick reply, i gonna try Edit : Working thanks Link to comment
ozulus Posted September 18, 2015 Author Share Posted September 18, 2015 I have one more problem. I converted string which is "Furkan Ozulus", but i want to get random characters from that string. So it would be like that : F _ r _ a _ _ z _ l _ s How can i do it ? Link to comment
Moderators IIYAMA Posted September 18, 2015 Moderators Share Posted September 18, 2015 I am not pro in strings, but this is what I can do. local testString = "Furkan Ozulus" local stringLength = string.len(testString ) local newString = "" for i=1,stringLength do if math.random(2) == 1 then newString = newString .. string.sub(testString,i,i) else newString = newString .. "_" end if i ~= stringLength then newString = newString .. " " end end outputChatBox(newString) Link to comment
ozulus Posted September 18, 2015 Author Share Posted September 18, 2015 Thank you so so much dude! That's what i want. Link to comment
Moderators IIYAMA Posted September 18, 2015 Moderators Share Posted September 18, 2015 np. 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