Creating regx trigger from an alias

Posted by Nozshand on Thu 01 Jan 2015 02:53 AM — 5 posts, 17,482 views.

#0
AddTriigerEx function seems to behave differently in command line and in an alias

I have following piece of script to create a trigger for me in an alias

AddTriggerEx ('number', '^\\d\-\\d$', 'SetVariable("number","\%1")', 1|32, -1, 0, '', '', 12, 100);

when I call the alias the new trigger's match-line is created as "^d-d$" but if I just send them through command line then new trigger is created correctly as "^\d-\d$"

What do I need to do to create a regx trigger in an alias?
Australia Forum Administrator #1
% symbols in aliases represent wildcards so you need to double them.

I.e. Change %1 to %%1
Australia Forum Administrator #2
You may also need to double the backslashes.
#3
Nick Gammon said:

You may also need to double the backslashes.


double backslashes did not work for me, I have

AddTriggerEx ('force', '^\d\-\d$', 'SetVariable("number","%%1")', 1|32, -1, 0, '', '', 12, 100);

in the alias and it still gives me ^d-d$, '%1' in response text is set correctly now though
Australia Forum Administrator #4
Quadruple the backslashes then.

In the send-to-script it already treats two backslashes as one and then Lua treats two as one as well so to put a single \ into a string you need four.