Skip to content
</>Inblix Dev ToolsAll tools

Number Regex Generator Online

Pull numeric values out of unstructured text — log lines, scraped pages, invoice descriptions. The default pattern handles signed integers and decimals.

How it works

The digit character class is the simplest part of this pattern, but deciding where a number stops is where it gets interesting. `\d` matches one digit; putting them in sequence with a quantifier, `\d+`, matches a run of one or more. That is the shortest useful form of "a whole number".

Decimals are handled with a non-capturing group: `(?:\.\d+)?`. The group is optional, so the pattern matches integers and decimals with one expression. The parentheses are marked non-capturing because you do not want them to occupy a capture group unless you intend to reference them — this matters when you use the group selector to pull out sub-parts.

A leading minus is handled by putting the sign outside the quantifier: `-?\d+`. Placing it inside, as `\d+-`, would match the minus sign as a standalone token and produce a spurious empty match.

Thousands separators and currency symbols need explicit handling. A number written as 1,234,567 does not match the default pattern as one number, because the commas break the digit run. To match formatted numbers including separators, use `-?\d[\d,]*(?:\.\d+)?` — note the character class rather than a repeated group, which is faster and avoids the backtracking risk of nesting quantifiers.

This tool rejects patterns with a quantified group inside another quantifier, such as `(\d+)+`. That shape can backtrack exponentially on a failing input and lock the browser tab with no way to recover, so it is refused up front with an explanation.

Use the Number Regex Generator

Numbers
Paste text on the left to see the result.

Try an example:

Runs entirely in your browser — nothing you paste is uploaded or logged.

Worked examples

Real input and the exact output this page produces.

Example 1

Text

                      lat=51.5074, count=42, delta=-7
                    

Numbers

                      51.5074
42
-7
                    

Frequently asked questions

How do I match thousands separators?

Use a character class rather than a repeated group: -?\d[\d,]*(?:\.\d+)?. It is faster and avoids the nested-quantifier backtracking risk.

Why is the decimal part optional?

So one expression matches both integers and decimals. Without the question mark, 42 would not match.

How do I get only the integer part of each match?

Change the capture group and select it with the group selector. A non-capturing group keeps the numbering predictable.

Others doing similar work.