2
2
3
3
include (" pcre.jl" )
4
4
5
+ const DEFAULT_OPTS = PCRE. UTF8
6
+
5
7
type Regex
6
8
pattern:: ByteString
7
9
options:: Int32
@@ -18,31 +20,30 @@ type Regex
18
20
new (pat, opts, re, ex)
19
21
end
20
22
end
21
- Regex (p:: String , s:: Bool ) = Regex (p, 0 , s)
22
- Regex (p:: String , o:: Integer ) = Regex (p, o, false )
23
- Regex (p:: String ) = Regex (p, 0 , false )
24
-
25
- copy (r:: Regex ) = r
26
-
27
- # TODO : make sure thing are escaped in a way PCRE
28
- # likes so that Julia all the Julia string quoting
29
- # constructs are correctly handled.
30
23
31
- macro r_str (pattern, flags... )
32
- options = PCRE . UTF8
33
- for fx in flags, f in fx
24
+ function Regex (pattern:: String , flags:: String , study :: Bool )
25
+ options = DEFAULT_OPTS
26
+ for f in flags
34
27
options |= f== ' i' ? PCRE. CASELESS :
35
28
f== ' m' ? PCRE. MULTILINE :
36
29
f== ' s' ? PCRE. DOTALL :
37
30
f== ' x' ? PCRE. EXTENDED :
38
31
error (" unknown regex flag: $f " )
39
32
end
40
- Regex (pattern, options)
33
+ Regex (pattern, options, study )
41
34
end
35
+ Regex (p:: String , o:: Integer ) = Regex (p, o, false )
36
+ Regex (p:: String , f:: String ) = Regex (p, f, false )
37
+ Regex (p:: String , s:: Bool ) = Regex (p, DEFAULT_OPTS, s)
38
+ Regex (p:: String ) = Regex (p, DEFAULT_OPTS, false )
39
+
40
+ macro r_str (pattern, flags... ) Regex (pattern, flags... ) end
41
+
42
+ copy (r:: Regex ) = r
42
43
43
44
function show (io, re:: Regex )
44
45
imsx = PCRE. CASELESS| PCRE. MULTILINE| PCRE. DOTALL| PCRE. EXTENDED
45
- if (re. options & ~ imsx) == PCRE . UTF8
46
+ if (re. options & ~ imsx) == DEFAULT_OPTS
46
47
print (io, ' r' )
47
48
print_quoted_literal (io, re. pattern)
48
49
if (re. options & PCRE. CASELESS ) != 0 ; print (io, ' i' ); end
0 commit comments