说我有一个:MatchResult
m
>>> var m = Regex("(?<foo>hello) world").find("hello world")!!
如何按名称访问名为“foo”的组?根据文档MatchGroupCollection
实现get(String)
operator,但如果我尝试它,我会得到一个异常:
>>> m.groups["foo"]
error: type mismatch: inferred type is String but Int was expected
m.groups["foo"]
^