我有一段代码,如下,以前写的,不命名不规范,都以小写的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();
}
}
}
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();
}
}
}
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中怎么实现这个正则的替换啊
本文参考链接:https://www.cnblogs.com/lexus/archive/2008/08/31/1280554.html