Test, validate and match regular expressions
This regex matches each line of multiline text, capturing the leading whitespace and the line's content while optionally consuming a trailing comma before the newline. With global and multiline flags enabled, it processes every line, making it ideal for find-and-replace reformatting tasks such as converting comma-separated query lists into Python-friendly syntax by stripping trailing commas while preserving indentation.