c#使用正则表达式匹配提取日期

string target_p ="2021/09/18";

string target_q ="2021-09-18";

格式yyyy/MM/dd:   

MatchCollection mt = Regex.Matches(target_p , "([0-9]{4}/[0-9]{2}/[0-9]{2})");

格式yyyy-MM-dd:   

MatchCollection mt = Regex.Matches(target_q, "([0-9]{4}-[0-9]{2}-[0-9]{2})");

posted @ 2021-09-18 14:17  迷海  阅读(1882)  评论(0)    收藏  举报