本文整理汇总了C#中System.Text.RegularExpressions.Match.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Match.ToString方法的具体用法?C# Match.ToString怎么用?C# Match.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.RegularExpressions.Match
的用法示例。
在下文中一共展示了Match.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MacroElementEvaluator
private string MacroElementEvaluator(Match m, bool toUnique, Item item, bool oldSyntax)
{
// Get the matched string.
var element = m.ToString();
var alias = "";
if(oldSyntax)
alias = getAttributeValue(m.ToString(), "macroAlias");
else
alias = getAttributeValue(m.ToString(), "alias");
if (!string.IsNullOrEmpty(alias))
{
var attributesToReplace = MacroAttributesWithPicker(alias);
if (this.RegisterMacroDependencies)
item.Dependencies.Add(alias, ItemProviders.ProviderIDCollection.macroItemProviderGuid);
foreach (var attr in attributesToReplace)
{
string regex = string.Format("(?<attributeAlias>{0})=\"(?<attributeValue>[^\"]*)\"", attr);
Regex rx = new Regex(regex, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
element = rx.Replace(element, match => MacroAttributeEvaluator(match, toUnique, item));
}
}
return element;
}
示例2: AttributeMatchEval
/// <summary>
/// Called to evaluate the HTML fragment corresponding to each
/// attribute's name/value in the code.
/// </summary>
/// <param name="match">The <see cref="Match"/> resulting from a
/// single regular expression match.</param>
/// <returns>A string containing the HTML code fragment.</returns>
private string AttributeMatchEval(Match match)
{
if(match.Groups[1].Success) //attribute value
return "<span class=\"kwrd\">" + match.ToString() + "</span>";
if(match.Groups[2].Success) //attribute name
return "<span class=\"attr\">" + match.ToString() + "</span>";
return match.ToString();
}
示例3: MatchEval
/// <summary>
/// Called to evaluate the HTML fragment corresponding to each
/// matching token in the code.
/// </summary>
/// <param name="match">The <see cref="Match"/> resulting from a
/// single regular expression match.</param>
/// <returns>A string containing the HTML code fragment.</returns>
protected override string MatchEval(Match match)
{
if (match.Groups[1].Success) //JavaScript code
{
//string s = match.ToString();
return jsf.FormatSubCode(match.ToString());
}
if (match.Groups[2].Success) //comment
{
var reader = new StringReader(match.ToString());
string line;
var sb = new StringBuilder();
while ((line = reader.ReadLine()) != null)
{
if (sb.Length > 0)
{
sb.Append("\n");
}
sb.Append("<span class=\"rem\">");
sb.Append(line);
sb.Append("</span>");
}
return sb.ToString();
}
if (match.Groups[3].Success) //asp tag
{
return "<span class=\"asp\">" + match.ToString() + "</span>";
}
if (match.Groups[4].Success) //asp C# code
{
return csf.FormatSubCode(match.ToString());
}
if (match.Groups[5].Success) //tag delimiter
{
return "<span class=\"kwrd\">" + match.ToString() + "</span>";
}
if (match.Groups[6].Success) //html tagname
{
return "<span class=\"html\">" + match.ToString() + "</span>";
}
if (match.Groups[7].Success) //attributes
{
return attribRegex.Replace(match.ToString(),
new MatchEvaluator(this.AttributeMatchEval));
}
if (match.Groups[8].Success) //entity
{
return "<span class=\"attr\">" + match.ToString() + "</span>";
}
return match.ToString();
}
示例4: JavaScriptMatch
private static string JavaScriptMatch(Match _m)
{
if (_m.Groups[1].Success && !string.IsNullOrEmpty(_m.Groups[1].Value))
return _m.ToString().Replace(_m.Groups[1].Value, string.Format("/*<![CDATA[*/{0}/*]]>*/", new ScriptPacker(ScriptPacker.PackerEncoding.None, true, false).Pack(_m.Groups[1].Value)));
return _m.ToString();
}
示例5: Evaluate
internal override String Evaluate(Match match) {
this.lastMatch = match;
Object[] args = new Object[this.cArgs];
if (this.cArgs > 0) {
args[0] = match.ToString();
if (this.cArgs > 1) {
int i = 1;
if (this.groupNumbers != null)
for (; i <= this.groupNumbers.Length; i++) {
Group group = match.Groups[this.groupNumbers[i-1]];
args[i] = group.Success ? group.ToString() : null;
}
if (i < this.cArgs) {
args[i++] = match.Index;
if (i < this.cArgs) {
args[i++] = this.source;
for (; i < this.cArgs; i++)
args[i] = null;
}
}
}
}
Object result = this.function.Call(args, null);
return match.Result(result is Empty ? "" : Convert.ToString(result));
}
示例6: LinkEvaluator
private string LinkEvaluator(Match match)
{
var matchedString = match.ToString();
var stringBuilder = new StringBuilder(matchedString);
if(matchedString.Contains("|"))
{
var index = matchedString.IndexOf("|", StringComparison.Ordinal);
matchedString = matchedString.Remove(index, stringBuilder.Length - index);
stringBuilder.Remove(index, stringBuilder.Length - index);
}
if(matchedString.Contains(":"))
{
var index = matchedString.IndexOf(":", StringComparison.Ordinal);
matchedString = matchedString.Remove(0, index);
stringBuilder.Remove(0, index);
}
if(matchedString.Contains("#"))
{
var index = matchedString.IndexOf("#", StringComparison.Ordinal);
//matchedString = matchedString.Remove(0, index);
stringBuilder.Remove(0, index);
}
stringBuilder.Replace("[", string.Empty);
stringBuilder.Replace("]", string.Empty);
return stringBuilder.ToString();
}
示例7: PerformWebResourceSubstitution
protected virtual string PerformWebResourceSubstitution(Match match)
{
var replacedString = match.ToString();
replacedString = replacedString.Replace(match.Value, ViewControl.Page.ClientScript.GetWebResourceUrl(
this.GetType(), match.Groups["resourceName"].Value));
return replacedString;
}
示例8: AddPerson
private static string AddPerson(Match m)
{
string x = m.ToString();
x = "<a href=" + HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/" + x.Trim('@') + ">" + x + "</a>";
//x = "<a href=" + HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/" + x.Trim('@') + ">" + x + "</a>";
return x;
}
示例9: Evaluator
private string Evaluator(Match match)
{
string replacement;
if (_emoticonReplacementLookup.TryGetValue(match.Value, out replacement))
{
return string.Format(replacement, match.Value);
}
return match.ToString();
}
示例10: EvaluateDefinedTerm
private string EvaluateDefinedTerm(Match match)
{
var stringBuilder = new StringBuilder(match.ToString());
stringBuilder.Replace(";", string.Empty);
stringBuilder.Replace(":", string.Empty);
stringBuilder.Append(".");
return stringBuilder.ToString();
}
示例11: match
private static string match(Match m)
{
string match = m.ToString();
if (m_replaceDict.ContainsKey(match))
{
return m_replaceDict[match];
}
throw new NotSupportedException();
}
示例12: MutateUri
private static string MutateUri(Match m)
{
var uri = m.ToString();
if (uri.Length <= 1)
{
return uri;
}
return uri[1].ToString().ToUpper();
}
示例13: ConvertMatchedDateToProperDateStamp
private static string ConvertMatchedDateToProperDateStamp(Match matchedDate)
{
string[] dateArray = Regex.Split(matchedDate.ToString(), "[-/]");
string usDate = string.Empty;
Debug.Assert(dateArray.Length <= 3);
Boolean hasYear = dateArray.Length == 3;
if (dateArray.Length < 3)
usDate = dateArray[1] + "/" + dateArray[0] + "/" + DateTime.Now.Year.ToString();
else
usDate = dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2];
return usDate;
}
示例14: EvaluateSection
private string EvaluateSection(Match match)
{
var stringBuilder = new StringBuilder(match.ToString());
stringBuilder.Replace("=", string.Empty);
var result = stringBuilder.ToString();
result = result.TrimEnd(' ');
result = result + ".";
return result;
}
示例15: MatchEval
/// <summary>
/// Called to evaluate the HTML fragment corresponding to each
/// attribute's name/value in the code.
/// </summary>
/// <param name="match">The <see cref="Match"/> resulting from a
/// single regular expression match.</param>
/// <returns>A string containing the HTML code fragment.</returns>
protected override string MatchEval(Match match)
{
if (match.Groups[1].Success) //attribute value
return "<span class=\"rem\">" + match.ToString() + "</span>";
if(match.Groups[2].Success) //attribute value
return "<span class=\"html\">" + match.ToString() + "</span>";
if(match.Groups[3].Success) //attribute name
return "<span class=\"attr\">" + match.ToString() + "</span>";
if (match.Groups[4].Success) //close tag
return "<span class=\"html\">" + match.ToString() + "</span>";
if (match.Groups[5].Success) //values
return "<span class=\"kwrd\">" + match.ToString().Replace(";","") + "</span>;";
return match.ToString();
}