0
pos = string.find("1.23x", ".")
print ( pos )

I always get 1, when the output should be 2. Even if I try this

pos = string.find("123x", ".")
print ( pos )

It still returns 1.

What am I doing wrong?

Cameron Ball
  • 4,048
  • 6
  • 25
  • 34
  • 1
    possible duplicate of [Corona string.find() : Finding "."](http://stackoverflow.com/questions/17522384/corona-string-find-finding) – Yu Hao Dec 06 '13 at 04:20
  • @YuHao, to be exact - this a [solution](http://stackoverflow.com/a/17525129/1150918). Use `%.` instead, because `.` is reserved and needs to be escaped. – Kamiccolo Dec 06 '13 at 14:11

1 Answers1

1

Forgot that Lua can use patterns, this works:

pos = string.find('1.23x', '.',1 ,true)
print ( pos )

The dot was matched as a pattern, the fourth argument sets the mode to plain, so it recognises the dot as a regular character.

Cameron Ball
  • 4,048
  • 6
  • 25
  • 34