|
| 15 Dec 2011 08:48 PM |
| I've been learning Lua for 2+ years, but I still have no clue what gsub does... can anyone sum it down for me so it's easier to understand? |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2011 08:51 PM |
string.gsub(STRING, PATTERN, REPLACEMENT, MAX)
Goes through STRING looking for any PATTERN and replacing PATTERN with REPLACEMENT.
You can also specify an amount of matches to find by supplying integer MAX. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 15 Dec 2011 08:52 PM |
string.gsub(YourString, A, B)
All arguments are strings. A copy of the string will be returned, except every time A occurs in the copy, it is replaced by "B"
print(string.gsub("Hello world!", "Hello", "Goodbye"))
>Goodbye world! |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2011 08:52 PM |
| Oh... thanks guys! :D:D:D:D:D:D |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2011 09:14 PM |
"A copy of the string will be returned"
It also returns the number of matches found. I forgot to mention it returns a copy and number of matches myself... >_< |
|
|
| Report Abuse |
|
|