diff options
Diffstat (limited to 'src/nre.nim')
-rw-r--r-- | src/nre.nim | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/nre.nim b/src/nre.nim index 3f06d33bb..2611ee7f6 100644 --- a/src/nre.nim +++ b/src/nre.nim @@ -78,8 +78,14 @@ type StudyError* = ref object of Exception +proc destroyRegex(self: Regex) = + pcre.free_substring(cast[cstring](self.pcreObj)) + self.pcreObj = nil + if self.pcreExtra != nil: + pcre.free_study(self.pcreExtra) + proc initRegex*(pattern: string, options = "Sx"): Regex = - new result + new(result, destroyRegex) result.pattern = pattern var errorMsg: cstring @@ -131,3 +137,6 @@ proc getNameToNumberTable(self: Regex): Table[string, int] = idx += 1 result[name] = num + +proc exec*(self: Regex, str: string): RegexMatch = + discard |