I need to check that a file contains some amounts that match a specific format:
- between 1 and 15 characters (numbers or ",")
- may contains at most one "," separator for decimals
- must at least have one number before the separator
- this amount is supposed to be in the middle of a string, bounded by alphabetical characters (but we have to exclude the malformed files).
I currently have this:
\d{1,15}(,\d{1,14})?
But it does not match with the requirement as I might catch up to 30 characters here.
Unfortunately, for some reasons that are too long to explain here, I cannot simply pick a substring or use any other java call. The match has to be in a single, java-compatible, regular expression.