I'm not sure that I understand your needs well, but I think you could use word boundaries, for example:
\b([1-9]\d*[.,]\d{2})\b
To not match dates, you can use:
(?:^|[^.,\d])(\d+[,.]\d\d)(?:[^.,\d]|$)
Explanation:
The regular expression: (?-imsx:(?:^|[^.,\d])(\d+[,.]\d\d)(?:[^.,\d]|$)) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- (?: group, but do not capture: ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- [^.,\d] any character except: '.', ',', digits (0-9) ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- \d+ digits (0-9) (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- [,.] any character of: ',', '.' ---------------------------------------------------------------------- \d digits (0-9) ---------------------------------------------------------------------- \d digits (0-9) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- (?: group, but do not capture: ---------------------------------------------------------------------- [^.,\d] any character except: '.', ',', digits (0-9) ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
source share