[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Matching non-escapped quote with Lua pattern
- From: Philipp Janda <siffiejoe@...>
- Date: Mon, 03 Mar 2014 21:19:07 +0100
Am 03.03.2014 19:34 schröbte Andrew Starks:
I'm having trouble finding a pattern that works for finding an
unescaped quote in a string. So:
[[\']] should not match
[[']] should match
I can get it to work with '([^%\\]")' , except at the beginning of the string.
You could put a dummy character at the beginning of the string ...
My suggestion:
local function qfind( s )
local ok, a, b = string.match( " "..s, "[^\\](\\*)%1()[\"']()" )
if ok then
return a-1, b-1
end
return nil
end
(But if you write an extra function for matching, you could as well try
the two different patterns and save the temporary string ...)
-Andrew
Philipp