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).

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