diff options
author | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-01-10 08:14:49 -0500 |
---|---|---|
committer | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-01-10 08:14:49 -0500 |
commit | c4d536f5817ec8b1e4a6342547e67f34884890f7 (patch) | |
tree | adb2d2406f3b98a5b94b898257ae863e12a7fb1c /src/nre.nim | |
parent | 3a6e7941cfbf2714c8ee67e5c91f6fcb644caa43 (diff) | |
download | Nim-c4d536f5817ec8b1e4a6342547e67f34884890f7.tar.gz |
Extend Regex, add RegexMatch
Diffstat (limited to 'src/nre.nim')
-rw-r--r-- | src/nre.nim | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/nre.nim b/src/nre.nim index 79d689bcd..381c80708 100644 --- a/src/nre.nim +++ b/src/nre.nim @@ -65,8 +65,13 @@ proc tokenizeOptions(opts: string): tuple[flags: int, study: bool] = type Regex* = ref object - pcreObj: ptr pcre.Pcre - pcreExtra: ptr pcre.ExtraData + pattern: string # not nil + pcreObj: ptr pcre.Pcre # not nil + pcreExtra: ptr pcre.ExtraData ## nil + + RegexMatch* = object + pattern: Regex + matchBounds: Slice[int] SyntaxError* = ref object of Exception pos*: int ## the location of the syntax error in bytes @@ -76,6 +81,7 @@ type proc initRegex*(pattern: string, options = "Sx"): Regex = new result + result.pattern = pattern var errorMsg: cstring var errOffset: cint |