Aquesta pàgina ofereix exemples d'ús de l'escapada correcta quan s'empren expressions regulars en diversos contextos.
Quan s'empra el constructor d'expressions de triggers, s'afegeix automàticament l'escapada correcta a les expressions regulars.
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: