User:松/Drafts/Extension:AbuseFilter/Rules format: Difference between revisions
Content added Content deleted
(Translation code removal.) |
(Translation code removal.) |
||
Line 615: | Line 615: | ||
<!--T:283--> |
<!--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> |
* 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> |
||
⚫ | |||
<translate> |
|||
<!--T:285--> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
== Keywords == |
== Keywords == |
||
Line 626: | Line 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. |
*<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. |
||
* |
*<code>in</code> returns true if the right-hand operand (a string) contains the left-hand operand.'''Note:'''empty strings are not contained in, nor contain, any other string (not even the empty string itself). |
||
* |
*<code>contains</code> works like <code>in</code>, but with the left and right-hand operands switched.'''Note:'''empty strings are not contained in, nor contain, any other string (not even the empty string itself). |
||
* |
*<code>rlike</code> (or <code>regex</code>) and <code>irlike</code> return true if the left-hand operand matches (contains) the [[w:Regular expression|regex]] pattern in the right-hand operand (<code>irlike</code> is case '''i'''nsensitive). |
||
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>). |
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: | Line 662: | ||
| <code> "o" in ["foo", "bar"]</code> |
| <code> "o" in ["foo", "bar"]</code> |
||
| True |
| True |
||
| |
| Due to the string cast |
||
|- |
|- |
||
| <code>"foo" regex "\w+"</code> |
| <code>"foo" regex "\w+"</code> |
||
Line 671: | Line 670: | ||
| <code>"a\b" regex "a\\\\b"</code> |
| <code>"a\b" regex "a\\\\b"</code> |
||
| True |
| True |
||
| rowspan= "2" | |
| rowspan= "2" | To look for the escape character backslash using regex you need to use either four backslashes or two <code>\x5C</code>. (Either works fine.) |
||
|- |
|- |
||
| <code>"a\b" regex "a\x5C\x5Cb"</code> |
| <code>"a\b" regex "a\x5C\x5Cb"</code> |