Page 1 of 1

string.gsub and "." don't work?

Posted: Sun Jun 24, 2007 12:53 am
by Genete
A call to this function

Code: Select all

string.gsub("hello.world.bye",  "." , "-")
returns

Code: Select all

--------------- 15
It would work as this:

Code: Select all

string.gsub("hello#world#bye",  "#" , "-")
returns

Code: Select all

hello-world-bye 3

Why the dot "." doesn't work in the string.gsub function?

:cry:

-G

Posted: Sun Jun 24, 2007 1:29 am
by Genete
The dot "." is a magic pattern parameter that represents any character
Using "%." instead it works!! :D


Thanks anyway!

-G

Posted: Sun Jun 24, 2007 3:30 am
by heyvern
If you are doing any type of string searches this should help out:

http://lua-users.org/wiki/PatternsTutorial

And this too:

http://lua-users.org/wiki/StringLibraryTutorial

-vern