Project

General

Profile

Scripting Regex » History » Version 32

Per Amundsen, 01/30/2016 01:33 AM

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