Skip to content

Instantly share code, notes, and snippets.

@fabiolimace
Last active January 1, 2025 23:15
Show Gist options
  • Save fabiolimace/36635926481e999731dfb06166e3b162 to your computer and use it in GitHub Desktop.
Save fabiolimace/36635926481e999731dfb06166e3b162 to your computer and use it in GitHub Desktop.
Validação de datas com expressões regulares levando em consideração os anos bissextos
#!/usr/bin/mawk -f
/^((([0][48]|[2468][048]|[13579][26])00)|([0-9][0-9]([0][48]|[2468][048]|[13579][26])))$/ { print $0; next; }
{ print $0 " INVALIDO" }
#!/usr/bin/bash
for i in `seq 1 2024`; do
printf "%04d\n" "$i" | ./validar-bissexto.awk | grep -v INVALIDO;
done;
#!/usr/bin/mawk -f
$0 ~ "^((29/02/((([0][48]|[2468][048]|[13579][26])00)|(([0-9]{2})([0][48]|[2468][048]|[13579][26]))))|(((0[1-9]|1[0-9]|2[0-8])/(0[1-9]|10|11|12)|(29|30)/(04|06|09|11)|(29|30|31)/(01|03|05|07|08|10|12))/([0-9]{4})))$" { print $0; next; }
{ print $0 " INVALIDO" }
#!/usr/bin/bash
for i in `seq 10000 -1 1`; do
date -d "$i days ago" +"%d/%m/%Y" | ./validar-data.awk | grep INVALIDO;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment