RegexBuddy使用例子,及Visual Studio中正则使用的请教

我有一段代码,如下,以前写的,不命名不规范,都以小写的get打头,我想把它改成以Get打头,于是想到了正则

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Utils
{
    
class  DateTimeHelper
    {
        public static string getYear()
        {
            
return  DateTime.Now.Year.ToString();
        }
        public string getMonth()
        {
            
return  Microsoft.VisualBasic.Strings.Right( " 00 "   +  DateTime.Now.Month.ToString(),  2 );
        }
        public string getDay()
        {
            
return  Microsoft.VisualBasic.Strings.Right( " 00 "   +  DateTime.Now.Day.ToString(),  2 );
        }
        public string getYYYYMMDD()
        {
            
return  this.getYear()  +  this.getMonth()  +  this.getDay();
        }
        public string getHour()
        {
            
return  vb.Right( " 00 "   +  DateTime.Now.Hour.ToString(),  2 );
        }
        public string getMinute()
        {
            
return  vb.Right( " 00 "   +  DateTime.Now.Minute.ToString(),  2 );
        }
        public string getSecond()
        {
            
return  vb.Right( " 00 "   +  DateTime.Now.Second.ToString(),  2 );
        }
        public string getMillsecond()
        {
            
return  DateTime.Now.Millisecond.ToString();
        }
        public string getHHMMSS()
        {
            
return  this.getHour()  +  this.getMinute()  +  this.getSecond();
        }
    }
}

我在RegexBuddy下使用

 这里修改后的,对你或许还有点用

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using vb 
=  Microsoft.VisualBasic.Strings;
namespace Utils
{
    
class  DateTimeHelper
    {
        public static string GetYear()
        {
            
return  DateTime.Now.Year.ToString();
        }
        public static string GetMonth()
        {
            
return  Microsoft.VisualBasic.Strings.Right( " 00 "   +  DateTime.Now.Month.ToString(),  2 );
        }
        public static string GetDay()
        {
            
return  Microsoft.VisualBasic.Strings.Right( " 00 "   +  DateTime.Now.Day.ToString(),  2 );
        }
        public static string GetYYYYMMDD()
        {
            
return  GetYear()  +  GetMonth()  +  GetDay();
        }
        public static string GetHour()
        {
            
return  vb.Right( " 00 "   +  DateTime.Now.Hour.ToString(),  2 );
        }
        public static string GetMinute()
        {
            
return  vb.Right( " 00 "   +  DateTime.Now.Minute.ToString(),  2 );
        }
        public static string GetSecond()
        {
            
return  vb.Right( " 00 "   +  DateTime.Now.Second.ToString(),  2 );
        }
        public static string GetMillsecond()
        {
            
return  DateTime.Now.Millisecond.ToString();
        }
        public static string GetHHMMSS()
        {
            
return  GetHour()  +  GetMinute()  +  GetSecond();
        }
    }
}

 烦请高手解答一下我的疑惑,在vistual studio 或是editplus中怎么实现这个正则的替换啊

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值