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 function (any)
concat
is used as example.
String content: \.+\"[a-z]+
Expression: concat("abc", "\\.\\\"[a-z]+")
Notice:
LLD macro function inside string parameter of function
Regular expression: \.+\"[a-z]+
LLD macro: {{#MACRO}.iregsub("\.+\\"[a-z]+", \1)}
Expression: concat("abc, "{{#MACRO}.iregsub(\"\\.+\\\\\"[a-z]+\", \\1)}")
Notice:
User macro with context inside string parameter of function
Regular expression: \.+\"[a-z]+
User macro with context: {$MACRO:regex:"\.+\\"[a-z]+"}
Expression: concat("abc, "{$MACRO:regex:\"\\.+\\\\\"[a-z]+\"}")
Notice:
LLD macro function inside user macro context inside 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:
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: