RegexMatch to NamedTuple?

aplavin
Sat, 30 Mar 2019 21:20:17 +0000
New to Julia

When parsing a string with regex like m = match(r"^(?<str_a>\S+) (?<str_b>\S+)$", "abc def") it is possible to get group values like m[:str_a] and so on. But how do I convert the match to namedtuple, (str_a = "abc", str_b = "def") in this case? I cannot find a way to do this in the documentation, or for that matter cannot find how to convert a regex match to any plain data structure like dict.

4 posts - 2 participants