From 1a5401ebcffdfa2e90888c1ce4e9126d993c67e8 Mon Sep 17 00:00:00 2001 From: Flaviu Tamas Date: Fri, 16 Jan 2015 19:11:28 -0500 Subject: s/match/find/g The implementation needs to match the API after all ;) --- src/nre.nim | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/nre.nim') diff --git a/src/nre.nim b/src/nre.nim index 3c1645456..eb0210084 100644 --- a/src/nre.nim +++ b/src/nre.nim @@ -317,11 +317,7 @@ proc matchImpl(str: string, pattern: Regex, start, endpos: int, flags: int): Reg raise newException(AssertionError, "Internal error: errno " & $execRet) proc match*(str: string, pattern: Regex, start = 0, endpos = -1): RegexMatch = - ## Returns a `RegexMatch` if there is a match between `start` and `endpos`, otherwise - ## it returns nil. - ## - ## if `endpos == -1`, then `endpos = str.len` - return str.matchImpl(pattern, start, endpos, 0) + return str.matchImpl(pattern, start, endpos, pcre.ANCHORED) iterator findIter*(str: string, pattern: Regex, start = 0, endpos = -1): RegexMatch = # see pcredemo for explaination @@ -364,10 +360,11 @@ iterator findIter*(str: string, pattern: Regex, start = 0, endpos = -1): RegexMa yield currentMatch proc find*(str: string, pattern: Regex, start = 0, endpos = -1): RegexMatch = - for match in str.findIter(pattern, start, endpos): - return match - - return nil + ## Returns a `RegexMatch` if there is a match between `start` and `endpos`, otherwise + ## it returns nil. + ## + ## if `endpos == -1`, then `endpos = str.len` + return str.matchImpl(pattern, start, endpos, 0) proc findAll*(str: string, pattern: Regex, start = 0, endpos = -1): seq[RegexMatch] = accumulateResult(str.findIter(pattern, start, endpos)) -- cgit 1.4.1-2-gfad0