Logsflags: gm
Java Stack Trace Line
Matches a single Java stack trace frame line.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("^\\s*at\\s+([\\w$.]+)\\(([^)]+)\\)$", "gm");
const input = "\tat com.example.MyClass.method(MyClass.java:42)";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
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+.
Go (RE2) code
goGo
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`(?m)^\s*at\s+([\w$.]+)\(([^)]+)\)$`)
input := ` at com.example.MyClass.method(MyClass.java:42)`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
regexengine-agnostic
^\s*at\s+([\w$.]+)\(([^)]+)\)$ (flags: gm)Raw source: ^\s*at\s+([\w$.]+)\(([^)]+)\)$
How it 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)
Common use cases
- •Error triage
- •Stack trace parsers
- •JVM observability
Related patterns
JSON Log Line (Single-Line Object)
LogsMatch a single-line JSON object — typical of structured logging from services like slog, Bunyan, or Pino.
Apache Common Log Format
LogsParses Apache Common Log Format entries.
CloudWatch Log Stream Path
LogsMatch AWS CloudWatch log group / stream paths like `/aws/lambda/my-function` or `/aws/ecs/cluster-name`.
Log Level
LogsMatches standard log level keywords in log lines.