c#里完美. 貌似在vb里不行,在VB程序里试了一下而已,不确定.
public string FiltrationDateString(string str)//过滤
{
string result = "";
string pattern = @"\d{4}(?<connectchar>[-/.])((1[0-2])|(0?\d))\k<connectchar>(([12]\d)|(3[01])|(0?\d))";
Regex reg = new Regex(pattern);
var matchs = reg.Matches(str);
int sum = 0;
for (int i = 0; i < matchs.Count; i++)
{
Match match = matchs[i];
if (i == matchs.Count - 1)
{
result += match.Value;
break;
}
result += (match.Value + "&");
}
return result;
}