How to allow only 2 digits and 1 digit after the comma (.)?

I have the problem that I can't get the proper RegExp together. My Goal is to allow up to 3 digits before the comma, and ONLY IF there is a decimal, then 1 digit after the comma. Which RegExp or Regexes do I have to use for this behavior?

Wanted allowed outcomes: 000.0, 00.0, 0.0, 000, 00, 0

thats the current code, but the problem is that here also 4 digits can be placed without a decimal:

inputFormatters: [

I already scrolled through these but they are not working for me:

Javascript Regex to allow only 2 digit numbers and 3 digit numbers as comma separated

Javascript regex to match only up to 11 digits, one comma, and 2 digits after it

Jquery allow only float 2 digit before and after dot

Flutter - Regex in TextFormField

Allow only two decimal number in flutter input?

Read more here:

Content Attribution

This content was originally published by Nuqo at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: