You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returns true if s[start..] matches the pattern and the captured substrings in the array matches. If it does not match, nothing is written into matches and false is returned.
when passing var matches: seq[string] , I would expect re.match to resize matches instead of keeping it empty
Example
import std/re
proctest=block:
var matches: array[2, string]
ifmatch("abcdefg", re"c(d)ef(g)", matches, 2):
for s in matches:
echo s # => d gblock:
# BUG: should give CT (or at least RT) errorvar matches: array[1, string]
ifmatch("abcdefg", re"c(d)ef(g)", matches, 2):
for s in matches:
echo s
block:
# BUG: should give CT (or at least RT) errorvar matches: array[3, string]
ifmatch("abcdefg", re"c(d)ef(g)", matches, 2):
for s in matches:
echo s
block:
# BUG (or odd design decision): matches doesn't get populated and# stays empty; should instead resize accordinglyvar matches: seq[string]
ifmatch("abcdefg", re"c(d)ef(g)", matches, 2):
for s in matches:
echo s
echo matches
test()
Current Output
d
g
d
g
@[]
Expected Output
CT error (if strings are known at compile time) or RT error
Honestly I'd rather we deprecate re in favor of nre instead of spending time fixing these issues (nre doesn't have that issue); but we should still document bugs until then
The text was updated successfully, but these errors were encountered:
this behavior is not documented (actually documentation is vague here): https://nim-lang.github.io/Nim/re.html#findAll.i%2Ccstring%2CRegex%2Cint%2Cint
var matches: seq[string]
, I would expectre.match
to resizematches
instead of keeping it emptyExample
Current Output
Expected Output
CT error (if strings are known at compile time) or RT error
Honestly I'd rather we deprecate re in favor of nre instead of spending time fixing these issues (nre doesn't have that issue); but we should still document bugs until then
The text was updated successfully, but these errors were encountered: