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 » Scripting Helpers
Home Search
 

Re: Strings

Previous Thread :: Next Thread 
StormRecon is not online. StormRecon
Joined: 15 Aug 2010
Total Posts: 2214
22 Feb 2013 12:50 PM
Alright, how would you be able to find letters in a string. I can't explain it well, but here's an example..

Apple

and I want to find 'app'

how would I do this?

Report Abuse
bibo5o is not online. bibo5o
Joined: 17 Jan 2009
Total Posts: 414
22 Feb 2013 12:53 PM
sub.string is the thing used for this I believe

word = "Apple"

print(word:sub.string(1,3))


dunno if that will work, I've only just touched the basics of that.
Report Abuse
StormRecon is not online. StormRecon
Joined: 15 Aug 2010
Total Posts: 2214
22 Feb 2013 12:55 PM
Already know that crap.

Anyhow, I'm making a database, and I need it to find models with words or letters inside the model name.

Example: I'm looking for 'subway'

List that pops up:


subway
ilikesubway
ihatesubway
1subway1

etc
Report Abuse
StormRecon is not online. StormRecon
Joined: 15 Aug 2010
Total Posts: 2214
22 Feb 2013 12:56 PM
By the way...

It's string.sub
Report Abuse
bibo5o is not online. bibo5o
Joined: 17 Jan 2009
Total Posts: 414
22 Feb 2013 01:04 PM
made that mistake again -_-

I have no Idea how you'd manage a database like that

Maybe a bunch of stringvalues and then check those stringvalues for the word subway

if it has them move them into a certain model and then a gui kicks up and takes all the strings in the model and copies the values into some textlabels. That would probably involve some string.sub too, but it may work.
Report Abuse
H1998Backup is not online. H1998Backup
Joined: 19 Feb 2013
Total Posts: 138
22 Feb 2013 01:08 PM
string.find(stringToSearch,stringToLookFor)

Returns the positions of these

print( string.find("Apple","App") )

> 1 3

print( string.find("BLAHIHH","HI") )

> 4 5
Report Abuse
H1998Backup is not online. H1998Backup
Joined: 19 Feb 2013
Total Posts: 138
22 Feb 2013 01:09 PM

You can also find all string functions here:

http://wiki.roblox.com/index.php/Function_Dump/String_Manipulation#string.find
Report Abuse
StormRecon is not online. StormRecon
Joined: 15 Aug 2010
Total Posts: 2214
22 Feb 2013 01:20 PM
What will it return if it's nil?
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
22 Feb 2013 02:02 PM
No no no no no.

Don't use string.find for that. Lua has pattern matching. And a powerful one!

local pat = "app"

local str = "Apple"

function GetWordInString(String, Word)
return String:lower():match(Word)
end
Report Abuse
AureusLetum is not online. AureusLetum
Joined: 17 Feb 2013
Total Posts: 738
22 Feb 2013 02:13 PM
@jobro - You just made a custom function that does the exact same thing as a library function with the addition of automatic casing. In other words, you turned two lines into three lines. Why, exactly?

http://wiki.roblox.com/index.php/User:ElectricBlaze
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
22 Feb 2013 04:00 PM
Above ^ I could have left out the function >_>

I am just pointing out that match works much better than find on such cases.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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