mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-12 12:19:40 +00:00
Extend Regex, add RegexMatch
This commit is contained in:
10
src/nre.nim
10
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
|
||||
|
||||
Reference in New Issue
Block a user