Jump to content

[HELP] String converting


ozulus

Recommended Posts

Posted

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.

  • Moderators
Posted
local testString  = "Furkan Ozulus" 
local newString = string.rep("_",string.len(testString )) 
outputChatBox(newString) 
  

Or:

local newString = string.rep("_ ",string.len(testString )) 
outputChatBox(newString) 

Posted

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 ?

  • Moderators
Posted

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) 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...