|
| 02 May 2012 07:03 PM |
| You can "Add" strings together using .. but can you "Subtract" them? |
|
|
| Report Abuse |
|
|
|
| 02 May 2012 07:07 PM |
| What do you mean subtract? |
|
|
| Report Abuse |
|
|
Drenkus
|
  |
| Joined: 03 May 2009 |
| Total Posts: 2380 |
|
|
| 02 May 2012 07:21 PM |
| You can, with string.sub() |
|
|
| Report Abuse |
|
|
DXPower
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
|
| 02 May 2012 08:07 PM |
@Drenkus
No you can't. That is for grabbing a part of a string from point "A" to point "B". That isn't subtracting, that's separating. In order to subtract, use gsub().
local s = "Hello World!" print(string.gsub(s, "World", "!!"))
--It removes World and replaces it with !!.
--It prints: Hello!!! --If you want to REMOVE World, do this:
string.gsub(s, "World", "")
With a Five-Guys burger in my hands, I am now invincible! |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 04 May 2012 07:01 AM |
Subtract 'World' from "Hello World!':
string.gsub("Hello World!","World","")
Add 'World' to "Hello !":
string.gsub("Hello !"," "," World") |
|
|
| Report Abuse |
|
|
DXPower
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
|
| 04 May 2012 05:24 PM |
@Bunny
Terribly inefficient. It would put it into the first space. The best you could do is this:
string.format("Hello %s !", "World") --Hello World ! string.format("This is a %s full of %s", "world", "tacos.") --This is a world full of tacos.
With a Five-Guys burger in my hands, I am now invincible! |
|
|
| Report Abuse |
|
|
| |
|
DXPower
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
|
| 05 May 2012 09:01 AM |
Link to string formatting:
http://wiki.roblox.com/index.php/String_Formatting
Annoying the crap out of you, one word at a time. -Says suoicodilaipxecitsaligirfilacrepus repeatedly- |
|
|
| Report Abuse |
|
|