regex - Modify a regular expression to allow leading/trailing whitespace -
my validation expression :
validationexpression="^(?:(?:(?:0?[13578]|1[02] )(\/|-)31 )|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30 )))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9] )$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8] ))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9] )$|^(0?2(\/|-)29 )(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00 )|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26] ))$"
how can change allow whitespace @ start or end of string?
try:
validationexpression="^\s*(?:(?:(?:0?[13578]|1[02] )(\/|-)31 )|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30 )))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9] )$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8] ))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9] )$|^(0?2(\/|-)29 )(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00 )|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26] ))\s*$"
\s* matches 0 or more whitespace characters. inserted @ start , end.
Comments
Post a Comment