A regexp that includes all combinations of numbers, dots and commas, but excludes records consisting of a single comma only

regex

^[\d,.]+$

The above regexp will choose all combinations of numbers, dots and commas. However, I need it not to return the records consisting of a single comma only.

How to adjust it?

I'm trying to find all numerical segments in my translation project in Trados, then find-and-replace all Russian-style decimal commas with decimal points. However, some translation segments in the document consist of a comma only: the parser is not very precise in Trados. I need not to change those commas into dots by mistake.

Best Answer

Use a lookahead:

^(?!,$)[\d,.]+$

where

(?!,$) is a negative lookahead, a zero-length assertion that makes sure we don't have a comma alone in the input string.