Fixes #5382
This commit is contained in:
parent
ac9c2126e6
commit
279e4b0451
2 changed files with 12 additions and 1 deletions
|
|
@ -290,7 +290,7 @@ proc find*(buf: cstring, pattern: Regex, matches: var openArray[string],
|
||||||
for i in 1..int(res)-1:
|
for i in 1..int(res)-1:
|
||||||
var a = rawMatches[i * 2]
|
var a = rawMatches[i * 2]
|
||||||
var b = rawMatches[i * 2 + 1]
|
var b = rawMatches[i * 2 + 1]
|
||||||
if a >= 0'i32: matches[i-1] = bufSubstr(buf, int(a), int(b)-1)
|
if a >= 0'i32: matches[i-1] = bufSubstr(buf, int(a), int(b))
|
||||||
else: matches[i-1] = nil
|
else: matches[i-1] = nil
|
||||||
return rawMatches[0]
|
return rawMatches[0]
|
||||||
|
|
||||||
|
|
|
||||||
11
tests/stdlib/tbug5382.nim
Normal file
11
tests/stdlib/tbug5382.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
discard """
|
||||||
|
output: '''
|
||||||
|
02
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
import re
|
||||||
|
|
||||||
|
let regexp = re"^\/([0-9]{2})\.html$"
|
||||||
|
var matches: array[1, string]
|
||||||
|
discard "/02.html".find(regexp, matches)
|
||||||
|
echo matches[0]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue