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

→‎Functions: Translation code removal.
(→‎Functions: Translation code removal.)
(→‎Functions: Translation code removal.)
Line 709:
| <code>norm</code> || Equivalent to <code>rmwhitespace(rmspecials(rmdoubles(ccnorm(arg1))))</code>.
|-
| <code>ccnorm</code> || Normalises confusable/similar characters in the argument, and returns a canonical form.A list of characters and their replacements can be found [[phab:source/Equivset/browse/master/data/equivset.in|on git]], e.g. <code>ccnorm( "Eeèéëēĕėęě3ƐƷ" ) === "EEEEEEEEEEEEE"</code>.<ref name="T27619">Be aware of [[phab:T27619]].You can use [[Special:AbuseFilter/tools]] to evaluate <code>ccnorm( "your string" )</code> to see which characters are transformed.</ref> The output of this function is always uppercase.
|-
| <code>ccnorm_contains_any</code> || <translate><!--T:327--> Normalises confusable/similar characters in the arguments, and returns true if the first string contains '''any''' string from the following arguments (unlimited number of arguments, logic OR mode).</translate> <translate><!--T:328--> A list of characters and their replacements can be found [[<tvar|1>phab:source/Equivset/browse/master/data/equivset.in</>|on git]].</translate>
|-
| <code>ccnorm_contains_all</code> || <translate><!--T:329--> Normalises confusable/similar characters in the arguments, and returns true if the first string contains '''every''' string from the following arguments (unlimited number of arguments, logic AND mode).</translate> <translate><!--T:330--> A list of characters and their replacements can be found [[<tvar|1>phab:source/Equivset/browse/master/data/equivset.in</>|on git]].</translate>
|-
| <code>specialratio</code> || <translate><!--T:331--> Returns the number of non-alphanumeric characters divided by the total number of characters in the argument.</translate>
|-
| <code>rmspecials</code> || <translate><!--T:332--> Removes any special characters in the argument, and returns the result.</translate> <translate><!--T:333--> (Equivalent to <tvar|1>s/[^\p{L}\p{N}]//g</>.)</translate>
|-
| <code>rmdoubles</code> || <translate><!--T:334--> Removes repeated characters in the argument, and returns the result.</translate>
|-
| <code>rmwhitespace</code> || <translate><!--T:335--> Removes whitespace (spaces, tabs, newlines).</translate>
|-
| <code>count</code> || <translate><!--T:336--> Returns the number of times the needle (first string) appears in the haystack (second string).</translate> <translate><!--T:337--> If only one argument is given, splits it by commas and returns the number of segments.</translate>
|-
| <code>rcount</code> || <translate><!--T:338--> Similar to <tvar|1><code>count</code></> but the needle uses a regular expression instead.</translate> <translate><!--T:339--> Can be made case-insensitive by letting the regular expression start with "<tvar|2>(?i)</>".</translate> <translate><!--T:405--> Please note that, for plain strings, this function can be up to 50 times slower than <tvar|1><code>count</code><ref>https://3v4l.org/S6IGP</ref></>, so use that one when possible.</translate>
|-
| <code>get_matches</code> || {{MW version-inline|MW 1.31+}} <translate><!--T:340--> Looks for matches of the regex needle (first string) in the haystack (second string).</translate> <translate><!--T:341--> Returns an array where the 0 element is the whole match and every <tvar|1><code>[n]</code></> element is the match of the n'th capturing group of the needle.</translate> <translate><!--T:342--> Can be made case-insensitive by letting the regular expression start with "<tvar|1>(?i)</>".</translate> <translate><!--T:343--> If a capturing group didn't match, that array position will take value of ''false''.</translate>
222

edits