Developer Tools5 min read•October 8, 2026

How to Test Regular Expressions and Format Raw SQL Queries in One Tool

Learn how to check a JavaScript regex against sample text with live match listing, then switch tabs to break a one-line SQL query into readable clauses.

S
SmartToolPack Dev Desk✓ Verified
Reviewed by the GreenCode Developer Tools Editorial Desk
Last Updated: October 8, 2026
Disclaimer: Calculations and results provided by this tool are mathematical estimates for informational and educational purposes only. They do not constitute professional financial, tax, or legal advice.
Featured Utility Tool

Regex & SQL Formatter

Open Regex & SQL Formatter

Introduction

Patterns and queries are both easy to get subtly wrong, and both are faster to fix with instant feedback. The Regex Tester tab runs a JavaScript RegExp against sample text and lists every match, while the SQL Formatter tab splits a single-line query onto clause-based lines with uppercased keywords. Both run in the browser.

Step-by-Step Instructions

  1. Click the Regex Pattern Tester tab and enter the pattern in the Regex Pattern field without surrounding slashes.
  2. Set the Flags field (keep g for all matches; add i for case-insensitive or m for multiline).
  3. Paste sample input into Test Text String and read the Matched Groups panel, which lists each match with its index.
  4. Switch to the SQL Query Formatter tab and paste the query into Raw Unformatted SQL.
  5. Read the Formatted SQL Output panel and click Copy SQL to copy the result.

Key Use Cases

  • Form validation: Confirm an email or phone pattern matches the expected inputs and nothing else.
  • Log parsing: Extract ids or timestamps from a block of log lines before writing a script.
  • Code review: Reformat a long ORM-generated query so joins and filters are visible at a glance.

Frequently Asked Questions

Why does the tester show an error when the g flag is removed?

Matches are collected with String.prototype.matchAll, which requires a global regular expression. Without g the browser throws, and the message appears in the Regex Syntax Error box. Keep g in the Flags field and combine it with i, m, s or u as needed.

Does the match list show capture groups?

No. The Matched Groups panel lists the full text of each match in order, not the individual capturing groups within it. To inspect a sub-part, adjust the pattern so the part you want is the whole match.

How does the SQL formatter decide where to break lines?

It inserts a line break before and uppercases SELECT, FROM, WHERE, INNER JOIN, LEFT JOIN, RIGHT JOIN, ON, ORDER BY, GROUP BY, LIMIT and HAVING, matching them case-insensitively. It does not indent, reflow column lists or validate syntax, so it works best on single-line queries built from those keywords.