|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 22 Feb 2013 12:56 PM |
By the way...
It's string.sub |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 22 Feb 2013 01:20 PM |
| What will it return if it's nil? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|