function to validate dates using regex in bash -
I have been able to validate two of the following dates to work like this:
function validate_dates () {# valid date to be yyyy-mm-dd local regex = "^ [[: points]] {4} - [[points:]] {2} - [[points:] "$ Dates" "$$" "$$" "$ {"} "$ dates" ("$ 1" "$ 2") printf "% s \ n" "$ {dates [@]} $ dates" "[__date" [$ __date = ~ $ regex]] || Error_ext "One of the dates is faulty!" validate_dates "2013-05-23" "2014 - # error_exit only function assistant message}
However when I call the function out with the call Is to exit 07-28 "
I found:
2013-05-23 2014-07-28 2013-05-23 in dates Is a defective!
Why does this break out properly formatted dates?
"^ [[points]] {4} - [[points:] {2} - [[digits]] {2} $ "
should probably be:
" ^ [[digits:]] {4} - [[Points:]] {2} - [[Issue:]] {2} $ "
You have" $ Dates "" $ {dates for __date [ / Code> In addition, should probably have missed some colons for __date.
If you want more than only 2 parameters or variable parameters, @]} "
"$ Dates"
Only the first element of the array is expanded.
From
local dates = ("$ @")
My version:
function validate_dates { Local regex = '^ [[: points:]] {4} - [[:: points:]] {2} - [[number:]] {2} $' printf '% s \ n "" $ @ "__ for; [[$ __ = ~ $ regex]] || Error_exit" $ __ is an invalid date. "}}
Comments
Post a Comment