This page provides examples of using correct escaping when using regular expressions in various contexts.
When using the trigger expression constructor, correct escaping in regular expressions is added automatically.
User macro with context
Regular expression: \.+\"[a-z]+
User macro with context: {$MACRO:regex:"\.+\\"[a-z]+"}
Notice:
LLD macro function
Regular expression: \.+\"[a-z]+
LLD macro: {{#MACRO}.iregsub("\.+\\"[a-z]+", \1)}
Notice:
LLD macro function inside user macro context
Regular expression: \.+\"[a-z]+
LLD macro: {{#MACRO}.iregsub("\.+\\"[a-z]+", \1)}
User macro with context: {$MACRO:"{{#MACRO}.iregsub(\".+\\\"[a-z]+\", \1)}"}
Notice:
String parameter of non-history function
String content: \.+\"[a-z]+
Expression: concat("abc", "\\.\\\"[a-z]+")
Notice:
String parameter of history function
String content: \.+\"[a-z]+
Expression: find(__ITEM_KEY__,,"regexp","\.+\\"[a-z]+")
Notice:
LLD macro function inside string parameter of non-history function
Regular expression: \.+\"[a-z]+
LLD macro: {{#MACRO}.iregsub("\.+\\"[a-z]+", \1)}
Expression: concat("abc, "{{#MACRO}.iregsub(\"\\.+\\\\\"[a-z]+\", \\1)}")
Notice:
LLD macro function inside string parameter of history function
Regular expression: \.+\"[a-z]+
LLD macro: {{#MACRO}.iregsub("\.+\\"[a-z]+", \1)}
Expression: find(__ITEM_KEY__,,"eq","{{#MACRO}.iregsub(\"\.+\\\"[a-z]+\", \1)}")
Notice:
User macro with context inside string parameter of non-history function
Regular expression: \.+\"[a-z]+
User macro with context: {$MACRO:regex:"\.+\\"[a-z]+"}
Expression: concat("abc, "{$MACRO:regex:\"\\.+\\\\\"[a-z]+\"}")
Notice:
User macro with context inside string parameter of history function
Regular expression: \.+\"[a-z]+
User macro with context: {$MACRO:regex:"\.+\\"[a-z]+"}
Expression: find(__ITEM_KEY__,,"eq","{$MACRO:regex:\"\.+\\\"[a-z]+\"}")
Notice:
LLD macro function inside user macro context inside non-history function
Regular expression: \.+\"[a-z]+
LLD macro: {{#MACRO}.iregsub("\.+\\"[a-z]+", \1)}
User macro with context: {$MACRO:"{{#MACRO}.iregsub(\".+\\\"[a-z]+\", \1)}"}
Expression: concat("abc, "{$MACRO:\"{{#MACRO}.iregsub(\\\".+\\\\\\\"[a-z]+\\\", \\1)}\"}")
Notice the three layers of escaping:
LLD macro function inside user macro context inside history function
Regular expression: \.+\"[a-z]+
LLD macro: {{#MACRO}.iregsub("\.+\\"[a-z]+", \1)}
User macro with context: {$MACRO:"{{#MACRO}.iregsub(\".+\\\"[a-z]+\", \1)}"}
Expression: find(__ITEM_KEY__,,"eq","{$MACRO:\"{{#MACRO}.iregsub(\\".+\\\\"[a-z]+\\", \1)}\"}")
Notice:
User macro with context just inside string
Regular expression: \.+\"[a-z]+
User macro with context: {$MACRO:regex:"\.+\\"[a-z]+"}
Inside string of some expression, for example: func(arg1, arg2, arg3)="{$MACRO:regex:\"\\.+\\\\\"[a-z]+\"}"
Notice: