Advertisement
andmalv

[Tip] Validar Hora (HH:MM, en 24h)

Nov 12th, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.27 KB | None | 0 0
  1. while [[ ! $hora =~ ^[0-9]{2}:[0-9]{2}$ || $HH -gt 23 || $MM -gt 59 ]]; do 
  2.     tput sc
  3.     read -ep " Hora (HH:MM, en 24h): " hora
  4.     tput rc
  5.     tput ed
  6.        
  7.     HH=${hora:0:2}
  8.     MM=${hora:3:2}
  9. done
  10.  
  11. # Donde
  12. #       ^[0-9]{2}:[0-9]{2}$ → 2 num seguidos de ':', seguido de 2 num
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement