generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: String Manipulation help.

Previous Thread :: Next Thread 
EcIiptic is not online. EcIiptic
Joined: 12 Aug 2009
Total Posts: 13737
20 May 2014 04:41 PM
I think string:sub() is read only so...

How would I do this:

String = "Hello"

String:sub(2,2) = "a"



How would I go about setting the individual character to a new one?

#Piano
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
20 May 2014 04:44 PM
text = 'daaamn'
for i = 1, text:len() do --wait()
print(text:sub(i,i))
end
Report Abuse
EcIiptic is not online. EcIiptic
Joined: 12 Aug 2009
Total Posts: 13737
20 May 2014 04:45 PM
wat

thats not at all what I asked.

im asking how to set a selected character in a string.

like

String = "Hello"

String:sub(2,2) = "a"

--String now equals "Hallo"

#Piano
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
21 May 2014 08:43 AM
txt = 'Hello'

for v in txt:gmatch('e') do
new = txt:gsub('e', 'a')
print(new)
end
Report Abuse
ajmhm1111 is not online. ajmhm1111
Joined: 22 Jun 2013
Total Posts: 164
21 May 2014 10:13 AM
Hello,

function overrideString(stringToOverride,p1,p2,stringToPlace)
return stringToOverride:sub(1,p1 - 1)..stringToPlace..stringToPlace:sub(p2 + 1,#stringToPlace)
end

print(overrideString("Hello",3,4,"ee")) -->prints Heeeo

Hope this helps

--ajmhm1111

Report Abuse
ajmhm1111 is not online. ajmhm1111
Joined: 22 Jun 2013
Total Posts: 164
21 May 2014 10:15 AM
Aah oops

function overrideString(stringToOverride,p1,p2,stringToPlace)
return stringToOverride:sub(1,p1 - 1)..stringToPlace..stringToOverride:sub(p2 + 1,#stringToOverride)
end

print(overrideString("Hello",3,4,"el")) -->prints Heelo

Sorry about that

--ajmhm1111
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image