This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
remiX's profile picture

string.find fail?

Started by remiX, 26 March 2013 - 09:21 AM
remiX #1
Posted 26 March 2013 - 10:21 AM
Picture says it all … xD
[attachment=1098:wtf.PNG]

What's going on there? How is it finding '/ *' ? ( two spaces )
faubiguy #2
Posted 26 March 2013 - 11:00 AM
The '*' symbol in a patterns means 0 or more of the previous character, so it finds a slash, a space, then 0 more spaces. If you want to only find strings that have at least two spaces, use '+', which means one or more.
l:find('\  +')
remiX #3
Posted 26 March 2013 - 11:27 AM
Oh i see, never knew * had an role in patterns.

What I wanted it to do is look for '/ *' in a string, how can you do that then?
Kingdaro #4
Posted 26 March 2013 - 11:29 AM
It'd be "/ ." if you want the * to stand for any character, or "/ %*" if you wanted a literal *.