find "." (dot) in string

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

find "." (dot) in string

Post by the underminer »

Code: Select all

dot = string.find (contents[1], [[.]])
doesn't work. Neither does

Code: Select all

dot = string.find (contents[1], ".")
Does anyone know why this happens or how to do this?
Behold! The Underminer got hold of a PSP
MikeHaggar
Posts: 116
Joined: Mon Jul 18, 2005 2:20 am

Re: find "." (dot) in string

Post by MikeHaggar »

the underminer wrote:

Code: Select all

dot = string.find (contents[1], [[.]])
doesn't work. Neither does

Code: Select all

dot = string.find (contents[1], ".")
Does anyone know why this happens or how to do this?
dot = string.find (contents, ".") ?
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

Post by the underminer »

no, contents is right. I'm trying to find "." in the array contents where i is the entry number. i = 1 So it reads from the first entry of contents. I'm not wrong there
Behold! The Underminer got hold of a PSP
Durante
Posts: 65
Joined: Sun Oct 02, 2005 6:07 am
Location: Austria

Post by Durante »

Easy, by default find does pattern matching, so . matches any character.
Read more: http://www.lua.org/pil/20.1.html

(I don't know how many threads I have answered with links to PIL already... just read it! - I didn't know Lua 3 weeks ago either ;))

Btw, what you want is "%."
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

Post by the underminer »

I knew it was a stupid question, but didn't know where to get the answer. thanks a million durante!
Behold! The Underminer got hold of a PSP
Post Reply