If your regex flavour supports lookahead assertions, you can use this:
^(?!(?:\d{17,}$|[,\d]{18,}$))(?:\d+(?:,\d+)?)$
See it here on Regexr
I removed the superfluous {1}
and made the group with the fraction optional.
The negative lookahead assertion (?!(?:\d{17,}$|[,\d]{18,}$))
is checking your length requirement. It fails if it finds 17 or more digits till the end OR 18 or more digits and commas till the end. That I allow multiple commas in the character class here is not a problem, that there is only one comma is ensured by the following pattern.