import re
regex = re.compile(r"(?<filename>[a-zA-Z0-9\\-\\.\\/_]+.d)(?<line>\(\d+),(?<column>\d+)\): (?<level>.+(?=:))(?<message>.*)")
test_str = ("source/parsers/x509.d(149,21): Error: function `std.typecons.Nullable!(Address[]).Nullable.length() const` is not callable using argument types `(ulong)`\n"
"source/parsers/x509.d(149,21): expected 0 argument(s), not 1\n"
"source/parsers/x509.d(151,60): Error: cannot implicitly convert expression `parseAddress(cast(const(char)[])split(cur_line[17], header.set_seperator)[i], null)` of type `std.socket.Address` to `Address[]`\n"
"source/parser.d(83,30): Error: template instance `parser.Parser.summarize!(X509)` error instantiating\n"
"Error /home/steveno/dlang/dmd-2.101.0/linux/bin64/dmd failed with exit code 1.\n\n\n"
"../lib/Miller.vala:32.3-32.12: error: The name `legth' does not exist in the context of `LibBalistica.Miller'\n"
" 32 | this.legth = 1.0;\n"
" | ^~~~~~~~~~")
match = regex.search(test_str)
if match:
print(f"Match was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html