I'm trying to switch over from perl to lua, since perl support under Lion seems to be heading into the "not in my lifetime" territory (for sad reasons, but still...)
So I have an event triggering on matches regexp for ^(.+)$ It's defined as:
require "shangrila"
process_line("%{regexp.1}")
This works great, unless the incoming line contains a " or ', in which case it barfs with:
%% Error: [string "?"]:2: ')' expected near 'that'
How do I get the string properly quoted so I can work with it?
Dealing with incoming strings with special characters in them
Started by blackbear, Aug 31 2011 08:56 PM
5 replies to this topic
#1
Posted 31 August 2011 - 08:56 PM
#2
Posted 01 September 2011 - 06:20 PM
I don't use Lua, but I'm assuming it's this:
process_line(AtlantisState["regexp.1"])
process_line(AtlantisState["regexp.1"])
#3
Posted 03 September 2011 - 07:18 PM
Nope, still getting the same error
#4
Posted 04 September 2011 - 12:26 PM
The latter /should/ work, since the regexp.1 state variable (as added to the Lua state) is a string literal; Lua should in theory already have it escaped, and does when I test it in a quicky test Lua script.
How are you calling the Lua script? If you can give me an easy repro case I'll take a look to see what might be happening.
How are you calling the Lua script? If you can give me an easy repro case I'll take a look to see what might be happening.
Rachel "Sparks" Blackman
Riverdark Studios
Riverdark Studios
#5
Posted 04 September 2011 - 07:46 PM
Ok, that's working now, I had a call to the other version elsewhere in the script. However, another question. I need to see blank lines that are sent from the server to figure out state, but the pattern:
(.*)
or
^(.*)$
With condition "matches regexp" doesn't fire the event on a blank line from the server.
(.*)
or
^(.*)$
With condition "matches regexp" doesn't fire the event on a blank line from the server.
#6
Posted 05 September 2011 - 08:04 PM
That seems like a legitimate bug; it looks like I'm not firing events on zero-length lines.
I'll change that for the next build.
Rachel "Sparks" Blackman
Riverdark Studios
Riverdark Studios
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











