|
| 27 Jan 2012 10:32 PM |
What is the pattern to remove all wait()'s using gsub? I try this:
scripters = "wait() print'Hi'" scripters = string.gsub(scripters,"wait()","")
print(scripters)
I get "() print'Hi'". Any help? |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2012 10:34 PM |
Why don't you just learn more about coroutines like I said... It is so much easier to make a constantly updating coroutine then just completely remove the wait function from your script builder...
⦅TNS⦆ |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2012 10:36 PM |
| :( I don't get coroutines, though. I've read a lot of stuff, I just understand them. My mind is too small to comprehend... |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2012 10:36 PM |
| and i think you would need to use string.find to search for 'wait' and then sub it at that point and search for ')' then cut of where wait starts and where ) ends :P |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2012 10:56 PM |
scripters = "wait() print'Hi'" scripters = string.gsub(scripters,"wait%p%p%s*","") print(scripters)
>print'Hi' |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2012 10:57 PM |
| You can actually take out the '%s*' it just removes the extra whitespace after 'wait()" |
|
|
| Report Abuse |
|
|
rcm
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 621 |
|
|
| 27 Jan 2012 11:35 PM |
The problem is that the parenthesis () are used for pattern captures: http://wiki.roblox.com/index.php/Patterns#Captures
To get around it, put a % infront of each parenthesis (% acts as an escape character). Ex:
scripters = "wait() print'Hi'" scripters = string.gsub(scripters,"wait%(%)","") print(scripters) |
|
|
| Report Abuse |
|
|
| |
|
|
| 28 Jan 2012 04:04 AM |
str = "wait()Hello! wait()This iwait()s wait()await() strwait()ing." str = str:gsub("wait%(%)", "") str = str:gsub("Wait%(%)", "") print(str)
It also works if wait uses a capitalized first letter, as that can be done too. |
|
|
| Report Abuse |
|
|