|
| 06 Sep 2015 07:38 PM |
local StartsWith = function(str1, str2) return str1:sub(1, #str2) == str2 end |
|
|
| Report Abuse |
|
|
Scripth
|
  |
| Joined: 23 Jun 2013 |
| Total Posts: 1724 |
|
|
| 06 Sep 2015 07:40 PM |
or local str='potato' if str:find('pot') then print(str:sub(1,str:find('pot')) end
>> 'pot' |
|
|
| Report Abuse |
|
|
Scripth
|
  |
| Joined: 23 Jun 2013 |
| Total Posts: 1724 |
|
|
| 06 Sep 2015 07:41 PM |
woops nvm im high af don't listen to me that prints >> 'p' not 'pot' u can use :find()==1 to check if it starts the string tho |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2015 07:43 PM |
local StartsWith = function(str1, str2, span) return str1:sub(span, #str2) == str2 end
print(StartsWith("abc", "bc", 2)) --> true |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2015 07:44 PM |
local StartsWith = function(str1, str2, span) return str1:sub(span or 1, #str2) == str2 end
print(StartsWith("abc", "bc", 2)) --> true |
|
|
| Report Abuse |
|
|