[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Matching non-escapped quote with Lua pattern
- From: Andrew Starks <andrew.starks@...>
- Date: Mon, 3 Mar 2014 12:34:12 -0600
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.
Here is a complete example of my issue. Note that the problem is in
the first result. Results 2 and 3 are fine:
``lua
pattern = '([^%\\]")'
s = "\"'[==[ sdhfjks ]===]\\\"'"
print(s:find(pattern))
--> nil
s2 = "\"'[==[ sdhfjks ]===]\"'"
print(s2:find(pattern))
--> 20 21 ]"
s3 = " \"'[==[ sdhfjks ]===]\\\"'"
print( s3:find(pattern))
--> 1 2 "
``
My pattern matching skills are out of solutions, except to check the
pattern twice, once for in the beginning and then again for elsewhere
in the string. Is there a way to do this with one pattern?
-Andrew