本文整理汇总了C#中System.Text.RegularExpressions.Regex.GetUpperBound方法的典型用法代码示例。如果您正苦于以下问题:C# Regex.GetUpperBound方法的具体用法?C# Regex.GetUpperBound怎么用?C# Regex.GetUpperBound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.RegularExpressions.Regex
的用法示例。
在下文中一共展示了Regex.GetUpperBound方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToHtml
public static string ConvertToHtml(string text) {
var finalResult = text;
try
{
var patterns = new[ ]
{
@"(?: +)?<card>(?:[\\ ]+)?([a-z0-9""][&\-=\p{Lu}\p{Ll}!.:""',#/・ 0-9]*\s*)(?:[!\\""'/[email protected]#$%^&*()]+)?</card>(?: +)?",
@"\[policy-ygo\]", @"\WPOLICY-KDE\W", @"\WPOLICY-PENALTY\W"
};
var replacements = new[ ]
{
@"<font color='blue'><u><a href='http://antitcb.com/cardlookup?CardName=$1' target='_blank'>$1</a></u></font>",
$"{YUGIOH_POLICY}", $"{KDE_POLICY}", $"{PENALTY_POLICY}"
};
for ( var i = 0 ; i <= patterns.GetUpperBound(0) ; i++ )
{
var regex = new Regex(patterns[ i ], RegexOptions.IgnoreCase);
if (!regex.IsMatch(finalResult)) { continue; }
finalResult = regex.Replace(finalResult, replacements[ i ]);
}
}
catch ( Exception e )
{
Console.WriteLine(e);
finalResult = "An error occurred. PM Anti with the text that should be here.";
}
var replaceDict = Matches(finalResult, @"'_blank'>(.+?)</a></u></font>").
Cast< Match >().
ToDictionary
(match => match.Groups[ 1 ].ToString(), match => match.Groups[ 1 ].ToString().Replace(" ", "+"));
return replaceDict.Aggregate
(finalResult,
(current, cardNameReplace) =>
Replace(current, $"CardName={cardNameReplace.Key}", $"CardName={cardNameReplace.Value}")).Trim();
}