当前位置: 首页>>代码示例>>C#>>正文


C# Match.ToString方法代码示例

本文整理汇总了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;
        }
开发者ID:jayvin,项目名称:Courier,代码行数:28,代码来源:MacroResolver.cs

示例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();
		}
开发者ID:haithemChkel,项目名称:nopCommerce_33,代码行数:17,代码来源:HtmlFormat.cs

示例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();
 }
开发者ID:491134648,项目名称:Farmer,代码行数:58,代码来源:HtmlFormat.cs

示例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();
            }
开发者ID:tforsberg,项目名称:z,代码行数:7,代码来源:RemoveHtmlWhiteSpace.cs

示例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));
 }
开发者ID:ArildF,项目名称:masters,代码行数:25,代码来源:regexpreplace.cs

示例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();
        }
开发者ID:mkaczynski,项目名称:Passim,代码行数:31,代码来源:TextFormattingCleaner.cs

示例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;
 }
开发者ID:CharlieBP,项目名称:AjaxControlToolkit,代码行数:7,代码来源:ComboBoxDesigner.cs

示例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;
        }
开发者ID:kkl,项目名称:TwitNearby,代码行数:8,代码来源:Utility.cs

示例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();
 }
开发者ID:4-Roads,项目名称:FourRoads.TelligentCommunity,代码行数:9,代码来源:EmoticonLogic.cs

示例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();
        }
开发者ID:mkaczynski,项目名称:Passim,代码行数:10,代码来源:SectionFormatter.cs

示例11: match

        private static string match(Match m)
        {
            string match = m.ToString();
            if (m_replaceDict.ContainsKey(match))
            {
                return m_replaceDict[match];
            }

            throw new NotSupportedException();
        }
开发者ID:vstrien,项目名称:KOCus,代码行数:10,代码来源:ReplaceString.cs

示例12: MutateUri

        private static string MutateUri(Match m)
        {
            var uri = m.ToString();

            if (uri.Length <= 1)
            {
                return uri;
            }

            return uri[1].ToString().ToUpper();
        }
开发者ID:typingdinosaur,项目名称:Readable-Urls,代码行数:11,代码来源:ReadableUrls.cs

示例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;
 }
开发者ID:wertkh32,项目名称:gg,代码行数:12,代码来源:DateTimeParser.cs

示例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;
        }
开发者ID:mkaczynski,项目名称:Passim,代码行数:12,代码来源:SectionFormatter.cs

示例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();
		}
开发者ID:rioka,项目名称:CodePaste.NET,代码行数:28,代码来源:CssFormat.cs


注:本文中的System.Text.RegularExpressions.Match.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。