Regular expression flags
To configure Template or Deeplink events, if necessary, you can specify regular expression flags.
Flag "i"
If this flag exists, regexp searches regardless of the case, does not distinguish between A and a.
This means that if i flag is set, the value that triggers the template can be written with both a small and a capital letter.
For example, if Template is triggered by the word Hello, with i flag, it will be triggered in the following options: Hello, hello, HeLlO, etc.
Flag "g"
G flag is called global. It enables the search for all matches in the string and does not stop the search after the first match. If this flag exists, regexp looks for all matches, otherwise only the first one.
For example, there is a regular expression /aa/ and the string aa aa aa.
Only one substring in this string corresponds to a regular expression, although in fact, we see that there should be three of them. It happens because regular expressions only look for the first match by default.
If we add flag g it to our regular expression, all aa substrings will be matched.
You can see an example of use here.
Flag "m"
Multiline mode is enabled by the m flag.
It only affects the behavior of ^ and $. In the multiline mode, they mean not only the beginning/end of the text, but also the beginning/end of each line in the text.
For example, there is a text:
1st place: Vinnie 2nd place: Piglet 3rd place: Heffalump
And the regular expression ^\d with g flag (search for a digit at the beginning of the text).
Without m flag, it will return only one. But if we add m flag, the search for a digit will be conducted in each line of the text, which is why we will get 1, 2, 3 in the answer.
You can see an example here.
The dollar symbol $ behaves similarly. The regular expression \d$ looks for the last digit in each line.
For example, there is such a text:
Winnie: 1 Piglet: 2 Heffalump: 3
Without m flag, $ anchor would indicate the end of the entire string, and only the last digit would be found.
You can see an example here.
To the beginning ↑