'BASH Validating user input with specific options

I need help in a piece of bash script that validates the user input. The only options allowed are:

  1. (a number) - ex.: 130
  2. (two or three numbers separated by space) - ex: 130 165 199
  3. (a range of numbers) - ex: 130-199
  4. (a specific char) - ex: P

If other option is inserted then informs the user of invalid format and asks again for the input variable. I've tried so many combinations but I'm not able to meet all the sentences. My code bellow:

while ! [[ $INPUT  =~ ^[0-9]+$ ]] || [[ $INPUT  =~ ^[0~9]+" "+[0-9]+" "+[0-9]+$ ]] || [[ $INPUT  =~ ^[0-9]+"-"+[0-9]+$ ]] || [[ $INPUT = [Pp] ]]
    do printf "Invalid format!. Repeat input:\n"
      read INPUT
    done

Thank you in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source