User:松/Drafts/Extension:AbuseFilter/Rules format: Difference between revisions

Translation code removal.
(Translation code removal.)
(Translation code removal.)
Line 615:
<!--T:283-->
* Use <tvar|1><code>_pst</code></> variables when you're really sure that non-PST variables aren't enough.</translate> <translate><!--T:284--> You may also conditionally decide which one to check: if, for instance, you want to examine a signature, check first if <tvar|1><code>added_lines</code></> contains <tvar|2><code><nowiki>~~~</nowiki></code></>;</translate>
* In general, when dealing with these variables, it's always much better to consume further conditions but avoid computing heavy stuff.</translate> <translate><!--T:286--> In order to achieve this, always put heavy variables as last conditions.</translate>
<translate>
 
<!--T:285-->
<translate><!--T:287--> Last but not least, note that whenever a variable is computed for a given filter, it'll be saved and any other filter will immediately retrieve it.</translate>This means that one single filter computing this variable counts more or less as dozens of filters using it.
* In general, when dealing with these variables, it's always much better to consume further conditions but avoid computing heavy stuff.</translate> <translate><!--T:286--> In order to achieve this, always put heavy variables as last conditions.</translate>
<translate><!--T:287--> Last but not least, note that whenever a variable is computed for a given filter, it'll be saved and any other filter will immediately retrieve it.</translate>This means that one single filter computing this variable counts more or less as dozens of filters using it.
 
== Keywords ==
Line 626 ⟶ 625:
 
*<code>like</code> (or <code>matches</code>) returns true if the left-hand operand matches the [[w:Glob (programming)#Syntax|glob pattern]] in the right-hand operand.
* <translate><!--T:293--> <tvar|1><code>in</code></> returns true if the right-hand operand (a string) contains the left-hand operand.</translate> '''<translate><!--T:294--> Note:</translate>''' <translate><!--T:295--> empty strings are not contained in, nor contain, any other string (not even the empty string itself).</translate>
* <translate><!--T:296--> <tvar|1><code>contains</code></> works like <tvar|2><code>in</code></>, but with the left and right-hand operands switched.</translate> '''<translate><!--T:297--> Note:</translate>''' <translate><!--T:298--> empty strings are not contained in, nor contain, any other string (not even the empty string itself).</translate>
* <translate><!--T:299--> <tvar|1><code>rlike</code></> (or <tvar|2><code>regex</code></>) and <tvar|3><code>irlike</code></> return true if the left-hand operand matches (contains) the [[w:Regular expression|regex]] pattern in the right-hand operand (<tvar|4><code>irlike</code></> is case '''i'''nsensitive).</translate>
 
The system uses [[w:Perl Compatible Regular Expressions|PCRE]].The only PCRE option enabled is <code>PCRE_UTF8</code> (modifier <code>u</code> [https://php.net/reference.pcre.pattern.modifiers in PHP]); for <code>irlike</code> both <code>PCRE_CASELESS</code> and <code>PCRE_UTF8</code> are enabled (modifier <code>iu</code>).
Line 663 ⟶ 662:
| <code> "o" in ["foo", "bar"]</code>
| True
| <translate><!--T:303--> Due to the string cast</translate>
|-
| <code>"foo" regex "\w+"</code>
Line 671 ⟶ 670:
| <code>"a\b" regex "a\\\\b"</code>
| True
| rowspan= "2" | <translate><!--T:304--> To look for the escape character backslash using regex you need to use either four backslashes or two <tvar|1><code>\x5C</code></>.</translate> <translate><!--T:305--> (Either works fine.)</translate>
|-
| <code>"a\b" regex "a\x5C\x5Cb"</code>
222

edits