79619563

Date: 2025-05-13 11:45:57
Score: 0.5
Natty:
Report link

In Julia, the match() function returns only the first match of the regular expression, which is why match(r"\d+", "10, 11, 12") gives "10" and stops there. This is intended behavior and differs from eachmatch(), which returns all matches in the string. The captures field is empty because your pattern r"\d+" doesn't include any capture groups—capture groups are defined using parentheses, like r"(\d+)". Without parentheses, there’s nothing to capture beyond the full match itself, which is accessible via m.match. To retrieve all numbers from the string, eachmatch(r"\d+", ...) is the correct approach.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Manas Parashar