Advertisement
andmalv

[Tip] Validar Fecha (DD/MM/AA)

Aug 26th, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.36 KB | None | 0 0
  1. while [[ (! $fecha =~ ([0-9]{2}/){2}[0-9]{2} || $DD -gt 31 || $MM -gt 12) ]]; do    
  2.     tput sc
  3.         read -ep " Fecha (DD/MM/AA): " fecha
  4.     tput rc
  5.     tput ed
  6.        
  7.         DD=$( echo $fecha | cut -d '/' -f 1 )
  8.         MM=$( echo $fecha | cut -d '/' -f 2 )
  9. done
  10.  
  11.  
  12. # Donde
  13. #   ([0-9]{2}/){2}[0-9]{2} → 2 conjuntos de 2 numeros, seguidos de /, seguido de 2 numeros
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement