Regex Error in newest Mushclient/addxml.trigger

Posted by Mendaloth on Fri 13 Jan 2012 01:27 AM — 7 posts, 28,850 views.

#0
The following code:
	addxml.trigger {  match = "^(.*?) looks very uncomfortable\.$", 
							regexp = true,
							sequence = 50,
							enabled = false,
							omit_from_output = false,
							name = key,
							script = "Process_Study_Message",
							group="study_triggers"
}


Produces this error:


Compile error
Plugin: Miniwindow_Plugin (called from world: Aardwolf)
Immediate execution
[string "Plugin"]:249: invalid escape sequence near '"^(.*?) looks very uncomfortable'
Error context in script:  
 249*:   addxml.trigger {  match = "^(.*?) looks very uncomfortable\.$", 
 250 :        regexp = true,
 251 :        sequence = 50,
 252 :        enabled = false,
 253 :        omit_from_output = false,


I know since the latest version of Mushclient it has been much more picky about regex errors, but for the life of me I can't figure out what the issue is here. It is actually an exact copy from a trigger that was created by convert to regex option.

#1
I should add that it worked fine under previous versions of Mushclient.
Australia Forum Administrator #2
I don't get an error executing that in the Immediate window.

Template:version
Please help us by advising the version of MUSHclient you are using. Use the Help menu -> About MUSHclient.
USA Global Moderator #3
Quote:
I don't get an error executing that in the Immediate window.
You would with Lua 5.2.

The Aardwolf MUSHclient Package uses Lua 5.2 semantics now, and Lua 5.2 strictly rejects invalid string escape sequences whereas 5.1.4 just used the literal follower.

To fix your pattern you need to change that \. to \\. because \. is not a valid string escape sequence. Keep in mind that your pattern is a string first and only becomes a regular expression after initial parsing. Even though you weren't getting an error before, I'm pretty sure it wasn't giving you quite the regex pattern you expected.
Amended on Fri 13 Jan 2012 03:44 AM by Fiendish
USA #4
Alternatively, use longstrings, which don't have escape sequences.

[[^(.*?) looks very uncomfortable\.$]]
Australia Forum Administrator #5
Fiendish said:

You would with Lua 5.2.


Which isn't officially supported by MUSHclient.

There have been so many changes to Lua 5.2, including incompatibilities with existing DLLs that I have chosen to stay away from it.

I thought when I saw that string that perhaps the backslash should be double-escaped, but since I couldn't reproduce it, I didn't say that.
USA Global Moderator #6
Nick Gammon said:

Fiendish said:

You would with Lua 5.2.


Which isn't officially supported by MUSHclient.

I try telling people to come to me first because of this, but they don't always listen. Sorry about the spillover.