Java Stack Trace Line in PY
Matches a single Java stack trace frame line.
Try it in the PY tester →Pattern
regexPY
^\s*at\s+([\w$.]+)\(([^)]+)\)$ (flags: gm)Python (re) code
pyPython
import re
pattern = re.compile(r"^\s*at\s+([\w$.]+)\(([^)]+)\)$", re.MULTILINE)
input_text = " at com.example.MyClass.method(MyClass.java:42)"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
How the pattern works
`^\s*at\s+` matches the indent and 'at' keyword. `([\w$.]+)` captures the fully-qualified method. `\(([^)]+)\)$` captures the source location.
Examples
Input
at com.example.MyClass.method(MyClass.java:42)Matches
at com.example.MyClass.method(MyClass.java:42)