Regular Expressions 101

Community Library

Community Library Entry

1

Regular ExpressionOpen Workspace

/
^\[(?<ts>[\d -:]+)\] (?:\w+\.)*(?<lvl>[A-Z]+): (?<msg>[^{]*?)(?:\{"exception":(?<exception>.* (?:at (?<file>.*):(?<line>\d+))?.*)?(?<stack>\[stacktrace\].*)?\})?(?<context>\{.*\})?$
/
s

Description
Created·2026-01-21 14:51
Updated·2026-01-21 15:00
Type·Match
Flavor·PCRE2 (PHP)

Extracts the following fields from a Laravel Log print:

  • Time Stamp (Date)
  • Log Level (supports optional prefix (ie. local.DEBUG))
  • Log Message
  • Exception | Context

If an exception is detected, the file reference (file path + line number), and optional stacktrace are captured.

Submitted by Jerren
Open Workspace