求一个正则表达式

Bigenius 2006-06-30 03:23:37
将"2006-06-19 0:0:0"转换为"20060619"
谢谢!
...全文
72 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
枫雅小憩 2006-06-30
  • 打赏
  • 举报
回复
string dateTimeStr=dt.ToString("yyyyMMdd");
dragon05 2006-06-30
  • 打赏
  • 举报
回复
将"2006-06-19 0:0:0"转换为"20060619"

public string __Replace(string strValue,string regexOld,string regexNew)
{
RegexOptions options = (RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.ExplicitCapture);
Regex reg = new Regex(regexOld,options);

return reg.Replace(strValue,regexNew);
}

public string retRegex(string str)
{
return __UBBReplace(str,@"(?<enc1>\d{4})(\-)(?<enc2>\d{1,2})(\-)(?<enc3>\d{1,2})([ 0-9:]{6,9})","${enc1}${enc2}${enc3}");
}
coolxyq 2006-06-30
  • 打赏
  • 举报
回复
Regex.Replace(timestring,"([:\\s]\\d+)|(-)","")

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧