regexfac.cs

来自「学习正则表达式的编写」· CS 代码 · 共 42 行

CS
42
字号
using System;
using System.Text;
using System.Text.RegularExpressions;

namespace RegexTool
{
	/// <summary>
	/// RegexFac 的摘要说明。
	/// </summary>
	public class RegexFac
	{
		private bool IsUL;
		private bool IsComment;
		private string regex;
		public RegexFac(string regex, bool UL, bool Comment)
		{
			this.regex = regex;
			this.IsUL = UL;
			this.IsComment = Comment;
		}

		public Regex GetRegex()
		{
			if ( IsUL==false && IsComment==false )
			{
				return ( new Regex(regex) );
			}
			if ( IsUL==true && IsComment==false )
			{
				return ( new Regex(regex, RegexOptions.IgnoreCase) );
			}
			if ( IsUL==false && IsComment==true )
			{
				return ( new Regex(regex, RegexOptions.IgnorePatternWhitespace) );
			}

			return ( new Regex(regex, RegexOptions.IgnorePatternWhitespace|RegexOptions.IgnoreCase) );

		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?