1 package frost.core
2
3 ====================================================================================================
4 Represents a regular expression that can be used for matching and parsing strings.
5 `RegularExpression` objects can be created explicitly from strings, but are more typically created
6 using the shorthand syntax: `/regex/`.
7 ====================================================================================================
8 class RegularExpression : Immutable {
9 constant MULTILINE := 1
10 constant CASE_INSENSITIVE := 2
11 constant DOTALL := 4
12
13 @private
14 def nativeHandle:builtin_int
15
16 ================================================================================================
17 Creates a new `RegularExpression`.
18 ================================================================================================
19 init(regex:String) {
20 init(regex, 0)
21 }
22
23 ================================================================================================
24 Creates a new `RegularExpression` with the given flags.
25 ================================================================================================
26 init(regex:String, flags:Int) {
27 compile(regex, flags)
28 }
29
30 ================================================================================================
31 Returns a `Matcher` which searches the given string.
32 ================================================================================================
33 @external(frostRegularExpressionMatcher)
34 function matcher(text:String):Matcher
35
36 @override
37 method cleanup() {
38 destroy()
39 }
40
41 @private
42 @external(frostRegularExpressionCompile)
43 method compile(regex:String, flags:Int)
44
45 @private
46 @external(frostRegularExpressionDestroy)
47 method destroy()
48 }