I'm just new to lua... and so I apologize if i'm missing something basic.
i'm running a simple test to see if i can find certain values in a string.
Here's the code:
print(string.find('fd@testca','.') )
Instead of failing, which is what I was expecting, I'm getting back:
mymachinename:/usr/share/std/test# lua test.lua
1 1
Can you tell me where I'm going wrong? Thanks.
This is because in Lua the find
method looks for a pattern, and .
represents any character.
You can use character sets to work around the problem:
print(string.find('fd@testca','[.]') )
Here is a link to a small demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With