From WikiChip
Editing mirc/regex
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 11: | Line 11: | ||
* --with-match-limit - around 1,000,000 | * --with-match-limit - around 1,000,000 | ||
* --with-match-limit-recursion - 999 | * --with-match-limit-recursion - 999 | ||
− | |||
− | |||
mIRC has four custom modifiers for regex: | mIRC has four custom modifiers for regex: | ||
Line 20: | Line 18: | ||
* u - Enable the (*UCP) option (makes \b and \w works for unicode letters) and the (*UTF8) option (forces the string and pattern to be interpreted as utf8). | * u - Enable the (*UCP) option (makes \b and \w works for unicode letters) and the (*UTF8) option (forces the string and pattern to be interpreted as utf8). | ||
− | mIRC | + | mIRC also supports 3 custom markers inside a pattern: |
− | + | * \cc - will match $chr(3) (control code for the color sequence) | |
− | + | * \co - will match $chr(15) (control code for ending a color sequence) | |
− | + | * \cb - will match $chr(2) (control code for the bold sequence) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | '''Note:''' mIRC remembers up to 50 regex matches. After 50 matches, the first match is overwritten and the backreferences for that match are lost. | |
− | mIRC remembers up to 50 regex matches. After 50 matches, the first match is overwritten and the backreferences for that match are lost. | ||
Example: | Example: | ||
Line 53: | Line 31: | ||
This represent one regular expression (or one pattern) with 2 captured backreferences. | This represent one regular expression (or one pattern) with 2 captured backreferences. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Regex Identifiers == | == Regex Identifiers == | ||
Line 77: | Line 41: | ||
If the /g modifier is used, that number can be greater than 1. | If the /g modifier is used, that number can be greater than 1. | ||
− | You may see a negative value being returned if an error occured | + | You may see a negative value being returned if an error occured: |
− | |||
− | |||
− | |||
− | |||
* -8 - you reached the maximum number of backtracks allowed, for example: $regex($str(a,4000),(a+a+)*b) | * -8 - you reached the maximum number of backtracks allowed, for example: $regex($str(a,4000),(a+a+)*b) | ||
− | |||
* -21 - you reached an internal recursion limit, for example: $regex($str(a, 1000), (a)+) | * -21 - you reached an internal recursion limit, for example: $regex($str(a, 1000), (a)+) | ||
− | |||
=== $regml === | === $regml === | ||
Line 97: | Line 55: | ||
'''Note''': $regml is a list of all captures accross all the matches made (/g modifier), which is often enough, but can be a problem in some cases. | '''Note''': $regml is a list of all captures accross all the matches made (/g modifier), which is often enough, but can be a problem in some cases. | ||
− | <source lang="mIRC">//noop $regex(name, teasat, /([es])(a)/g) | echo -a $regml(name, 0) : $regml(name, 1) -- $regml(name, 2) -- $regml(name,3) -- $regml(name,4)</source>would display " | + | <source lang="mIRC">//noop $regex(name, teasat, /([es])(a)/g) | echo -a $regml(name, 0) : $regml(name, 1) -- $regml(name, 2) -- $regml(name,3) -- $regml(name,4)</source>would display "2 : e -- a -- s -- a " |
You can now access the Nth captured group for a given match number with {{mIRC|$regmlex}}. | You can now access the Nth captured group for a given match number with {{mIRC|$regmlex}}. | ||
Line 125: | Line 83: | ||
Special markers can be used inside the <subtext> parameter of $regsubex: | Special markers can be used inside the <subtext> parameter of $regsubex: | ||
− | * \0 - Returns the number of | + | * \0 - Returns the number of matches. |
* \n - Returns the current match number. | * \n - Returns the current match number. | ||
* \t - Returns the current match text (same as $regml(\n)). | * \t - Returns the current match text (same as $regml(\n)). |