Page 1 of 1

Matching a Dot with regex...

Posted: Tue Jan 20, 2009 3:59 pm
by 3cmSailorfuku
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?

Re: Matching a Dot with regex...

Posted: Tue Jan 20, 2009 10:33 pm
by zer0
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

Re: Matching a Dot with regex...

Posted: Wed Jan 21, 2009 11:02 am
by 3cmSailorfuku
Thank you, works like that.