Reputation: 311
I am attempting some pattern matching in Lua and have hit a small problem. I am trying to match everything from the first newline character in my data up to the following pattern _\x0C
.
here is the code that has the problem:
configmatch = string.match(response, "\n(.+)(['_\x0C'])")
it seems to be working some of the time, other times it is "cutting short" the expected output. the problem is probably to do with this: (['_\x0C']) but i have been unable to resolve it. Does anyone know how to fix this?
Upvotes: 3
Views: 180
Reputation: 72412
If you want _\x0C
literally in the string, you need to use "\n(.-_\\x0C)"
. If you mean underscore followed by formfeed, use "\n(.-_\012)"
, because there are no \x
escapes in Lua (5.1).
Upvotes: 3