Scripting Regex » History » Version 42
Per Amundsen, 07/20/2017 04:18 PM
1 | 1 | Per Amundsen | {{>toc}} |
---|---|---|---|
2 | |||
3 | h1. Regular Expressions |
||
4 | |||
5 | 39 | Per Amundsen | *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.* |
6 | 1 | Per Amundsen | |
7 | 36 | Per Amundsen | 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. |
8 | |||
9 | AdiIRC uses the .NET regular expression engine, while mIRC uses the PCRE engine, some differences are converted from PCRE to .NET while others are not possible. |
||
10 | 33 | Per Amundsen | |
11 | 13 | Per Amundsen | Read more about .NET regular expressions: |
12 | |||
13 | http://regexhero.net/reference/ |
||
14 | https://msdn.microsoft.com/en-us/library/hs600312%28v=vs.110%29.aspx |
||
15 | https://msdn.microsoft.com/en-us/library/az24scfc%28v=vs.110%29.aspx |
||
16 | http://www.regular-expressions.info/dotnet.html |
||
17 | |||
18 | 42 | Per Amundsen | _See also [[$regex]], [[$regsub]], [[$regsubex]], [[$regml]]._ |
19 | |||
20 | 1 | Per Amundsen | h1. Modifiers |
21 | |||
22 | /g /G - Enables global match. |
||
23 | 10 | Per Amundsen | /i /I - Enables case in-sensitive. |
24 | 31 | Per Amundsen | /S - Strips any [[Formatting_Text|control codes]] before matching ([[$hfind]] will ignore this). |
25 | 1 | Per Amundsen | /s - Enables single line match. |
26 | /m /M /c /C - Enables multi line match. |
||
27 | /x /X - Eliminates unescaped white space from the pattern. |
||
28 | 9 | Per Amundsen | /U - Enables non greedy mode. (Tries to replace greedy patterns with non greedy patterns + > +?, * -> *?) |
29 | 32 | Per Amundsen | <notextile>/u - Enables UTF8 instead of ASCII regular expression.</notextile> |
30 | 1 | Per Amundsen | |
31 | 34 | Per Amundsen | h1. Differences between .NET and PCRE |
32 | 1 | Per Amundsen | |
33 | 41 | Per Amundsen | When PCRE support is not available, AdiIRC translate some patterns PCRE patterns into .NET patterns. |
34 | 17 | Per Amundsen | |
35 | 30 | Per Amundsen | <notextile>(*UTF8)/(*UTF) -> Enables UTF8 instead of ASCII regular expression.</notextile> |
36 | 6 | Per Amundsen | <notextile>(?R) -> .*</notextile> |
37 | <notextile>(?2) -> .*</notextile> |
||
38 | <notextile>(?1) -> .*</notextile> |
||
39 | 4 | Per Amundsen | <notextile>++ -> +</notextile> |
40 | 5 | Per Amundsen | <notextile>[:alnum:] -> a-zA-Z0-9</notextile> |
41 | <notextile>[:alpha:] -> a-zA-Z</notextile> |
||
42 | <notextile>[:ascii:] -> \x00-\x7F</notextile> |
||
43 | <notextile>[:blank:] -> \s\t</notextile> |
||
44 | <notextile>[:cntrl:] -> \x00-\x1F\x7F</notextile> |
||
45 | <notextile>[:digit:] -> 0-9</notextile> |
||
46 | <notextile>[:graph:] -> \x21-\x7E</notextile> |
||
47 | <notextile>[:lower:] -> a-z</notextile> |
||
48 | <notextile>[:print:] -> \x20-\x7E</notextile> |
||
49 | <notextile>[:punct:] -> !"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~</notextile> |
||
50 | <notextile>[:space:] -> \s\t\r\n\v\f</notextile> |
||
51 | <notextile>[:upper:] -> A-Z</notextile> |
||
52 | 8 | Per Amundsen | <notextile>[:word:] - > A-Za-z0-9_</notextile> |
53 | 5 | Per Amundsen | <notextile>[:xdigit:] -> A-Fa-f0-9</notextile> |
54 | <notextile>\cc -> \x003</notextile> |
||
55 | <notextile>\co -> \x00F</notextile> |
||
56 | <notextile>\cb -> \x002</notextile> |
||
57 | <notextile>\x\{([A-Fa-f0-9]{1,4})\} -> \uXXXX</notextile> |
||
58 | 24 | Per Amundsen | <notextile>\Q \E tries to escapes all characters in between</notextile> |
59 | 1 | Per Amundsen | |
60 | \K is not available in .NET, use (<=abc)d instead. |
||
61 | |||
62 | 35 | Per Amundsen | These have no .NET counterpart: |
63 | 13 | Per Amundsen | |
64 | 1 | Per Amundsen | code (?{…}) |
65 | 25 | Per Amundsen | recursive (R), (R1), (R&name) |
66 | 1 | Per Amundsen | define (DEFINE). |
67 | |||
68 | 34 | Per Amundsen | List of differences between .NET and PCRE https://stackoverflow.com/questions/3417644/translate-perl-regular-expressions-to-net |