Celeb Glow
updates | February 27, 2026

Regex to include decimals

(\d+)[^0-9]+(\d+)[^1-9]+(\d+)

The above expression recognizes three consecutive groups of integers. How would it also recognize decimals?

for example:

234.34 x 455.44 x 455.33

the result:

(1) 234.34 (2) 455.44 (3) 455.33

1 Answer

If there is allways 3 groups, use:

(\d+(?:\.\d+)?)\D+(\d+(?:\.\d+)?)\D+(\d+(?:\.\d+)?)

This will match 3 groups of float/integer.

Expanation:

( # start group 1 \d+ # 1 or more digits (?: # start non capture group \. # dot \d+ # 1 or more digits )? # end group, optional
) # end group 1
\D+ # 1 or more non digits

Same explanation for the rest of regex.

If you want to match only float (not integer), use: (\d+\.\d+)\D+(\d+\.\d+)\D+(\d+\.\d+)

Demo

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy