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 » Scripters
Home Search
 

Re: Your new favorite function

Previous Thread :: Next Thread 
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
06 Sep 2015 07:38 PM
local StartsWith = function(str1, str2)
return str1:sub(1, #str2) == str2
end
Report Abuse
Scripth is online. 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 is online. 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
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
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
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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