本文整理汇总了C#中RegExp类的典型用法代码示例。如果您正苦于以下问题:C# RegExp类的具体用法?C# RegExp怎么用?C# RegExp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegExp类属于命名空间,在下文中一共展示了RegExp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValidDINCode
bool IsValidDINCode(jsString code)
{
var pattern_noIdChar = new RegExp("[A-NP-Z1-9]{1}[0-9]{12}");
var pattern = new RegExp(@Html.RawHasQuote(BarcodeBLL.DINIdChar) + "[A-NP-Z1-9]{1}[0-9]{14}");
return pattern_noIdChar.test(code) || pattern.test(code);
}
示例2: IsValidProductCode
bool IsValidProductCode(jsString code)
{
if (code.length != @BarcodeBLL.productLength) return false;
var pattern = @Html.RawHasQuote(BarcodeBLL.productIdChar) + "[A-DE-Z1-9]{1}[0-9]{4}[A-Za-z0-9]{1}[A-Z0-9]{1}[a-z0-9]{1}";
var regx = new RegExp(pattern);
return regx.test(code);
}
示例3: IsValidDeleteCode
bool IsValidDeleteCode(jsString code)
{
if (code.length != @BarcodeBLL.deleteLength) return false;
var pattern = new RegExp(@Html.RawHasQuote(BarcodeBLL.deleteIdChar) + "[0-9]");
return pattern.test(code);
}
示例4: StringMatchesBothRegexAutomaton
public void StringMatchesBothRegexAutomaton(string pattern1, string pattern2, string matchingString)
{
var automaton1 = new RegExp(pattern1).ToAutomaton();
var automaton2 = new RegExp(pattern2).ToAutomaton();
var intersection = automaton1.Intersection(automaton2);
Assert.True(intersection.Run(matchingString));
}
示例5: btnHighLight_Click
protected void btnHighLight_Click(object sender, EventArgs e)
{
string _error = string.Empty;
// 检查用户输入的数据.
if (CheckControlValue(this.ddlLanguage.SelectedValue,
this.tbCode.Text, out _error))
{
// 初始化根据匹配选项用来保存不同语言代码
// 及其相关正则表达式的散列表变量.
Hashtable _htb = CodeManager.Init();
// 初始化合适的集合对象.
RegExp _rg = new RegExp();
_rg = (RegExp)_htb[this.ddlLanguage.SelectedValue];
this.lbResult.Visible = true;
if (this.ddlLanguage.SelectedValue != "html")
{
// 在标签控件中显示高亮的代码.
this.lbResult.Text = CodeManager.Encode(
CodeManager.HighlightCode(
Server.HtmlEncode(this.tbCode.Text)
.Replace(""", "\""),
this.ddlLanguage.SelectedValue, _rg)
);
}
else
{
// 在标签控件中显示高亮的代码.
this.lbResult.Text = CodeManager.Encode(
CodeManager.HighlightHTMLCode(this.tbCode.Text, _htb)
);
}
}
else
{
this.lbError.Visible = true;
this.lbError.Text = _error;
}
}
示例6: TestGetRandomAcceptedString
public virtual void TestGetRandomAcceptedString()
{
int ITER1 = AtLeast(100);
int ITER2 = AtLeast(100);
for (int i = 0; i < ITER1; i++)
{
RegExp re = new RegExp(AutomatonTestUtil.RandomRegexp(Random()), RegExp.NONE);
Automaton a = re.ToAutomaton();
Assert.IsFalse(BasicOperations.IsEmpty(a));
AutomatonTestUtil.RandomAcceptedStrings rx = new AutomatonTestUtil.RandomAcceptedStrings(a);
for (int j = 0; j < ITER2; j++)
{
int[] acc = null;
try
{
acc = rx.GetRandomAcceptedString(Random());
string s = UnicodeUtil.NewString(acc, 0, acc.Length);
Assert.IsTrue(BasicOperations.Run(a, s));
}
catch (Exception t)
{
Console.WriteLine("regexp: " + re);
if (acc != null)
{
Console.WriteLine("fail acc re=" + re + " count=" + acc.Length);
for (int k = 0; k < acc.Length; k++)
{
Console.WriteLine(" " + acc[k].ToString("x"));
}
}
throw t;
}
}
}
}
示例7: MakeConcatenation
private static RegExp MakeConcatenation(RegExp exp1, RegExp exp2)
{
if ((exp1.kind == Kind.RegexpChar || exp1.kind == Kind.RegexpString)
&& (exp2.kind == Kind.RegexpChar || exp2.kind == Kind.RegexpString))
{
return RegExp.MakeString(exp1, exp2);
}
var r = new RegExp();
r.kind = Kind.RegexpConcatenation;
if (exp1.kind == Kind.RegexpConcatenation
&& (exp1.exp2.kind == Kind.RegexpChar || exp1.exp2.kind == Kind.RegexpString)
&& (exp2.kind == Kind.RegexpChar || exp2.kind == Kind.RegexpString))
{
r.exp1 = exp1.exp1;
r.exp2 = RegExp.MakeString(exp1.exp2, exp2);
}
else if ((exp1.kind == Kind.RegexpChar || exp1.kind == Kind.RegexpString)
&& exp2.kind == Kind.RegexpConcatenation
&& (exp2.exp1.kind == Kind.RegexpChar || exp2.exp1.kind == Kind.RegexpString))
{
r.exp1 = RegExp.MakeString(exp1, exp2.exp1);
r.exp2 = exp2.exp2;
}
else
{
r.exp1 = exp1;
r.exp2 = exp2;
}
return r;
}
示例8: MakeComplement
private static RegExp MakeComplement(RegExp exp)
{
var r = new RegExp();
r.kind = Kind.RegexpComplement;
r.exp1 = exp;
return r;
}
示例9: MakeCharRange
private static RegExp MakeCharRange(char from, char to)
{
var r = new RegExp();
r.kind = Kind.RegexpCharRange;
r.from = from;
r.to = to;
return r;
}
示例10: MakeChar
private static RegExp MakeChar(char @char)
{
var r = new RegExp();
r.kind = Kind.RegexpChar;
r.c = @char;
return r;
}
示例11: MakeInterval
internal static RegExp MakeInterval(int min, int max, int digits)
{
RegExp r = new RegExp();
r.kind = Kind.REGEXP_INTERVAL;
r.Min = min;
r.Max = max;
r.Digits = digits;
return r;
}
示例12: MakeOptional
private static RegExp MakeOptional(RegExp exp)
{
var r = new RegExp();
r.kind = Kind.RegexpOptional;
r.exp1 = exp;
return r;
}
示例13: MakeRepeat
private static RegExp MakeRepeat(RegExp exp, int min, int max)
{
var r = new RegExp();
r.kind = Kind.RegexpRepeatMinMax;
r.exp1 = exp;
r.min = min;
r.max = max;
return r;
}
示例14: Match
public EcString[] Match(EcString pattern)
{
var r = new RegExp(pattern.value);
return r.Match(this.value).Select(match => new EcString(match)).ToArray();
}
示例15: TestSpecialCase
public void TestSpecialCase()
{
RegExp re = new RegExp(".?");
Automaton automaton = re.ToAutomaton();
CharacterRunAutomaton cra = new CharacterRunAutomaton(automaton);
ByteRunAutomaton bra = new ByteRunAutomaton(automaton);
// make sure character dfa accepts empty string
Assert.IsTrue(cra.IsAccept(cra.InitialState));
Assert.IsTrue(cra.Run(""));
Assert.IsTrue(cra.Run(new char[0], 0, 0));
// make sure byte dfa accepts empty string
Assert.IsTrue(bra.IsAccept(bra.InitialState));
Assert.IsTrue(bra.Run(new byte[0], 0, 0));
}