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

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

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

Post 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
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

The dot "." is a magic pattern parameter that represents any character
Using "%." instead it works!! :D


Thanks anyway!

-G
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post 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
Post Reply