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