Matching a Dot with regex...

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Post Reply
Message
Author
User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Matching a Dot with regex...

#1 Post by 3cmSailorfuku » Tue Jan 20, 2009 3:59 pm

I'm currently using string.gsub(); to match & replace a dot with regex.
eg.

Everybody needs somebody to love.wsasdagsegadasd.dasftj
Everybody needs somebody to love. I can't love.asdsgewgfawd

Off this example I can tell that a valid sentence would consist of a ". " and an invalid sentence of ".".
My problem now is, that you cannot use a dot to match except if you're escaping it (which would be \\.),
but does not work.

What Regex do I need to use to match a simple dot?

zer0
Posts: 213
Joined: Sat Feb 16, 2008 11:55 pm

Re: Matching a Dot with regex...

#2 Post by zer0 » Tue Jan 20, 2009 10:33 pm

Try "%.", Expressions use "%" instead of "\" in Lua.
Nick Gammon wrote: There are some "magic characters" (such as %) that have special meanings. These are:


^ $ ( ) % . [ ] * + - ?


If you want to use those in a pattern (as themselves) you must precede them by a % symbol.
Ref:
http://www.gammon.com.au/forum/?id=6034

User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Re: Matching a Dot with regex...

#3 Post by 3cmSailorfuku » Wed Jan 21, 2009 11:02 am

Thank you, works like that.

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests