Scripting Regex » History » Revision 53
Revision 52 (Per Amundsen, 07/20/2017 04:27 PM) → Revision 53/60 (Per Amundsen, 07/20/2017 04:27 PM)
{{>toc}}
h1. Regular Expressions
"Regular expressions":https://en.wikipedia.org/wiki/Regular_expression is a powerful tool to match text using a pattern, they can be used in many places such as searching log files, searching text-buffers, highlight matching and scripting, .
_See also [[$regex]], [[$regsub]], [[$regsubex]], [[$regml]]._
h1. Regular Expressions Engines
*As of 2.9 AdiIRC has built-in support for "PCRE2":https://github.com/ltrzesniewski/pcre-net expressions provided that "Visual C++ 2015 x86":https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x86.exe is installed for 32 bit AdiIRC or "Visual C++ 2015 x64":https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe is installed for 64 bit AdiIRC.*
AdiIRC will automatically use PCRE2 if available, although it can be disabled by typing *[[/setoption]] Misc UsePcre False*, in this case AdiIRC will fallback to .NET regular expressions.
The .NET regular expression engine is different from the PCRE engine which mIRC uses, some differences are converted from PCRE to .NET while others are not possible.
*Read more about PCRE2 regular expressions.*
http://www.regular-expressions.info/pcre2.html
http://www.regular-expressions.info/tutorial.html
*Read more about .NET regular expressions:*
http://regexhero.net/reference/
https://msdn.microsoft.com/en-us/library/hs600312%28v=vs.110%29.aspx
https://msdn.microsoft.com/en-us/library/az24scfc%28v=vs.110%29.aspx
http://www.regular-expressions.info/dotnet.html
h1. Modifiers
/g /G - Enables global match.
/i /I - Enables case in-sensitive match.
/S - Strips any [[Formatting_Text|control codes]] before matching ([[$hfind]] will ignore this).
/s - Enables single line match.
/m /M /c /C - Enables multi line match.
/x /X - Eliminates unescaped white space from the pattern.
/U - Enables non greedy mode. (Tries to replace greedy patterns with non greedy patterns + > +?, * -> *?)
<notextile>/u - Enables UTF8 instead of ASCII regular expression.</notextile>
h1. Differences between .NET and PCRE
When PCRE support is not available, AdiIRC translate some patterns PCRE patterns into .NET patterns.
<notextile>(*UTF8)/(*UTF) -> Enables UTF8 instead of ASCII regular expression.</notextile>
<notextile>(?R) -> .*</notextile>
<notextile>(?2) -> .*</notextile>
<notextile>(?1) -> .*</notextile>
<notextile>++ -> +</notextile>
<notextile>[:alnum:] -> a-zA-Z0-9</notextile>
<notextile>[:alpha:] -> a-zA-Z</notextile>
<notextile>[:ascii:] -> \x00-\x7F</notextile>
<notextile>[:blank:] -> \s\t</notextile>
<notextile>[:cntrl:] -> \x00-\x1F\x7F</notextile>
<notextile>[:digit:] -> 0-9</notextile>
<notextile>[:graph:] -> \x21-\x7E</notextile>
<notextile>[:lower:] -> a-z</notextile>
<notextile>[:print:] -> \x20-\x7E</notextile>
<notextile>[:punct:] -> !"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~</notextile>
<notextile>[:space:] -> \s\t\r\n\v\f</notextile>
<notextile>[:upper:] -> A-Z</notextile>
<notextile>[:word:] - > A-Za-z0-9_</notextile>
<notextile>[:xdigit:] -> A-Fa-f0-9</notextile>
<notextile>\cc -> \x003</notextile>
<notextile>\co -> \x00F</notextile>
<notextile>\cb -> \x002</notextile>
<notextile>\x\{([A-Fa-f0-9]{1,4})\} -> \uXXXX</notextile>
<notextile>\Q \E tries to escapes all characters in between</notextile>
\K is not available in .NET, use (<=abc)d instead.
These have no .NET counterpart:
code (?{…})
recursive (R), (R1), (R&name)
define (DEFINE).
List of differences between .NET and PCRE https://stackoverflow.com/questions/3417644/translate-perl-regular-expressions-to-net