eg. 2001-10-10
法1: Use mode modifier
(?x)\d{4} #Year
- #Separator
\d{2} # Month
- #Separator
\d{2} # Day
法2: Enable Free-space mode
\d{4} #Year
- #Separator
\d{2} # Month
- #Separator
\d{2} # Day
法3: (?#) mode
(?#year)\d{4}(?#Separator)-(?#Month)\d{2}-(?#Day)\d{2}
原文链接:https://www.f2er.com/regex/361807.html