Jump to content




string.find fail?


  • You cannot reply to this topic
3 replies to this topic

#1 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

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 )

#2 faubiguy

  • Members
  • 213 posts

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('\  +')


#3 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

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?

#4 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

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 *.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users