惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
博客园_首页
IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 司徒正美
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
Jina AI
Jina AI
月光博客
月光博客
小众软件
小众软件
S
SegmentFault 最新的问题
量子位
阮一峰的网络日志
阮一峰的网络日志
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - shcity

Troubleshooting on TransactionScope Parse string to JSON object Parse date in js blockUI doesn't close when download file in asp.net define namespace in JS Dense_Rank(), Row_Number(), Rank() in sql server reading and writing variable through lock in SSIS script task Fix the issue that cannot open SSIS in BIDS three ways creating custom helpers to show RadioButtonList in MVC using JavaScriptSerializer to serialize object to json using ISerializable to control serialization and deserialization ViewStateAutoManager ReportingService formatting Build my own DataTable split a string into an array through comma div with separated html template - shcity 半透明的div对话框 foreach 的自动转化类型 在Ajax1.0中调用页面CS文件中的方法
正则表达式替换日期
shcity · 2010-12-13 · via 博客园 - shcity

正则表达式替换日期

            string str = @"test_{@ReportDate:yyyyMMdd}\{@ReportDate:yyyy}\{@ReportDate:MM}\{@ReportDate:dd}\ss.xls";
            Regex regex 
= new Regex(@"\{@ReportDate:(?<p>[a-zA-Z]*)\}");
            DateTime time 
= DateTime.Now;string r = regex.Replace(str, match =>
            {
                var p 
= match.Groups["p"].Value;
                var t 
= time.ToString(p);
                
return t;
            });

posted on 2010-12-13 13:24  shcity  阅读(891)  评论(0)    收藏  举报