diff options
author | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-01-16 19:11:28 -0500 |
---|---|---|
committer | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-01-16 19:11:28 -0500 |
commit | 1a5401ebcffdfa2e90888c1ce4e9126d993c67e8 (patch) | |
tree | 609c549632de3244488212356dcd89b035d64069 /src/nre.nim | |
parent | ca3e72ee27be61ea5d89357867906da9cd0b2f05 (diff) | |
download | Nim-1a5401ebcffdfa2e90888c1ce4e9126d993c67e8.tar.gz |
s/match/find/g
The implementation needs to match the API after all ;)
Diffstat (limited to 'src/nre.nim')
-rw-r--r-- | src/nre.nim | 15 |
1 files changed, 6 insertions, 9 deletions
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)) |