• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RegularExpressions.Match类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Text.RegularExpressions.Match的典型用法代码示例。如果您正苦于以下问题:C# Match类的具体用法?C# Match怎么用?C# Match使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Match类属于System.Text.RegularExpressions命名空间,在下文中一共展示了Match类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CleanupMatch

        private static string CleanupMatch(Match match)
        {
            if(match.Groups["a"].Success)
                return match.Groups["a"].Value.ToUpper();

            return match.Groups["b"].Success ? match.Groups["b"].Value : string.Empty;
        }
开发者ID:nick-randal,项目名称:UsefulCSharp,代码行数:7,代码来源:StringExtensions.cs


示例2: Handle

        public string Handle(string input, Match match, IListener listener)
        {
            var query = match.Groups[1].Value;
            var tl = new TorrentLeech();
            var results = tl.Search(query);
            var res = string.Empty;
            var count = 0;

            foreach(var result in results)
            {
                if (count > 7)
                    break;
                res += count++ + ": " + result.Title + ": " + result.Size + " MB" + Environment.NewLine;
            }

            Brain.Pipe.ListenNext((input2, match2, listener2) =>
                                      {
                                          if (match2.Value == "cancel" || match2.Value == "none" || match2.Value == "nevermind")
                                              return "Cancelled";

                                          var index = -1;
                                          int.TryParse(match2.Groups[1].Value, out index);
                                          if (index == -1 || index >= results.Count)
                                              return "Cancelled";

                                          var selected = results[index];
                                          selected.Download();
                                          return "Downloading: " + selected.Friendly;
                                      }, "cancel|none|nevermind", @"download (\d+)");
                    return res;
        }
开发者ID:taimur38,项目名称:Yaar,代码行数:31,代码来源:TorrentCommand.cs


示例3: InjectAssets

        protected string InjectAssets(string markup, Match match)
        {
            if (match == null)
            {
                return markup;
            }

            using (var writer = new StringWriter())
            {
                writer.Write(markup.Substring(0, match.Index));

                WriteLinks(writer, @"<link type=""text/css"" rel=""stylesheet"" href=""{0}"" />",
                           Compressor.CompressCss(GetSources(CssLinks)));
                WriteInlines(writer, "<style>", "</style>", CssInlines);
                WriteLinks(writer, @"<script type=""text/javascript"" src=""{0}""></script>",
                           Compressor.CompressJavascript(GetSources(JavascriptLinks)));
                WriteInlines(writer, @"<script type=""text/javascript"">", "</script>", JavascriptInlines);

                WriteInlines(
                    writer,
                    @"<script type=""text/javascript"">jQuery(document).ready(function () {",
                    "});</script>",
                    DomReadyInlines);

                writer.Write(markup.Substring(match.Index));
                return writer.ToString();
            }
        }
开发者ID:jlarsson,项目名称:MvcAssets,代码行数:28,代码来源:AssetsInjectorBase.cs


示例4: Handle

 public IEnumerable<string> Handle(string input, Match match, IListener listener)
 {
     var tl = new TorrentLeech();
     var movies = tl.GetEntries(TorrentLeech.Movies).Distinct().Take(20).ToArray();
     var names = movies.Select(o => o.Friendly).ToArray();
     Brain.Pipe.ListenOnce((i, m, l) =>
         {
             var movie = m.Groups[1].Value;
             var entry = movies.FirstOrDefault(o => o.Friendly.ToLower().Contains(movie));
             if(entry == null)
                 return;
             if(!entry.Download())
             {
                 Brain.Pipe.ListenNext((s, match1, listener1) =>
                     {
                         if (match1.Value == "yes")
                         {
                             entry.Download(true);
                             listener1.Output(Speech.Yes.Parse());
                             listener1.Output("I shall redownload it.");
                             return;
                         }
                         listener1.Output(Speech.Yes.Parse());
                         listener1.Output("I won't redownload it.");
                     }, "yes", "no");
                 l.Output("You've already downloaded that sir. Do you want to redownload it?");
             }
             else
             {
                 l.Output("Downloading " + entry.Friendly + "...");
             }
         }, "download (.+)");
     yield return "Here are the latest films. Do you want to download any of them?";
     yield return string.Join(", ", names) + "\r\n";
 }
开发者ID:csyolen,项目名称:Jarvis,代码行数:35,代码来源:MoviesCommand.cs


示例5: Transform

		public void Transform(Match match, MarkdownReplacementArgs args)
		{
			args.Output.Append("<p>");
			args.Encoding.Transform(args, match.Matches[0]);
			args.Output.AppendUnixLine("</p>");
			args.Output.AppendUnixLine();
		}
开发者ID:halid-durakovic,项目名称:Eto.Parse,代码行数:7,代码来源:ParagraphSection.cs


示例6: OnFieldMatch

 protected override NextInstruction OnFieldMatch(RecorderContext context, string source, ref Match match)
 {
     var ins=baseRecorder.OnFieldMatchPublic(context, source, ref match);
     if (ins == NextInstruction.Return)
         context.FieldBuffer[context.SourceHeaderInfo["__full_text"]] = source;
     return ins;
 }
开发者ID:salimci,项目名称:Legacy-Remote-Recorder,代码行数:7,代码来源:PaloAltoUnifiedSyslogRecorder.cs


示例7: TranslateLambda

 public override string TranslateLambda( string codeLine, Match lambdaMatch )
 {
     var part0 = codeLine.Substring( 0, lambdaMatch.Groups[1].Length - 2 );
     var part2 = lambdaMatch.Groups[2].Captures[0].Value;
     var part1 = (lambdaMatch.Groups[1].Captures[0].Value.Trim().EndsWith( "()", StringComparison.OrdinalIgnoreCase ) ? null : ", ");
     return string.Format("{0}{1}delegate{2}{{", part0, part1, part2);
 }
开发者ID:peterjoh,项目名称:NHaml,代码行数:7,代码来源:CSharp2TemplateCompiler.cs


示例8: Replace

 public string Replace(Match m) {
     Console.WriteLine("WARNING: Assume equality: ");
     Console.WriteLine(m_SrcStr);
     Console.WriteLine(m.Groups[1].Captures[0].ToString());
     // this.ReplacedContent = m.Groups[1].Captures[0].ToString(); //replace text from PO filde by text from sources
     return "_('" + m_ReplaceBy + "')";
 }
开发者ID:bravesoftdz,项目名称:dvsrc,代码行数:7,代码来源:Substitution.cs


示例9: RegexLexerContext

 /// <summary>
 /// Initializes a new isntance of the <see cref="RegexLexerContext"/> class
 /// </summary>
 /// <param name="position">the position into the source file</param>
 /// <param name="match">the regular expression match data</param>
 /// <param name="stateStack">The stack of states</param>
 /// <param name="ruleTokenType">The token type the rule specified to emit</param>
 public RegexLexerContext(int position, Match match, Stack<string> stateStack, TokenType ruleTokenType)
 {
     Position = position;
     Match = match;
     StateStack = stateStack;
     RuleTokenType = ruleTokenType;
 }
开发者ID:akatakritos,项目名称:PygmentSharp,代码行数:14,代码来源:RegexLexer.cs


示例10: MatchSubstring

        private static Match[] MatchSubstring(string i_source, string i_matchPattern, bool i_uniqueMatch)
        {
            //<note> use RegexOptions.Multiline, otherwise it will treat the whole thing as 1 string
            Regex regex = new Regex(i_matchPattern, RegexOptions.Multiline);

            MatchCollection matchCollection = regex.Matches(i_source);

            Match[] result;
            if (!i_uniqueMatch)
            {
                result = new Match[matchCollection.Count];
                matchCollection.CopyTo(result, 0);
            }
            else
            {
                //<note> cannot use HashSet<Match> because each Match object is unique, even though they may have same value (string). Can use HashSet<string>
                //SortedList is more like sorted Dictionary<key, value>
                SortedList uniqueMatchCollection = new SortedList();
                foreach(Match match in matchCollection)
                {
                    if (!uniqueMatchCollection.ContainsKey(match.Value))
                    {
                        uniqueMatchCollection.Add(match.Value, match);
                    }
                }

                result = new Match[uniqueMatchCollection.Count];
                uniqueMatchCollection.Values.CopyTo(result, 0);     //<note> cannot use uniqueMatchCollection.CopyTo(...) since SortedList member is not type-match with destination array member
            }

            Console.WriteLine("Found {0} matches", result.Length);
            return result;
        }
开发者ID:hsn6,项目名称:csharp_cookbook,代码行数:33,代码来源:EnumerateMatches.cs


示例11: BindingMatch

 public BindingMatch(StepBinding stepBinding, Match match, object[] extraArguments, StepArgs stepArgs)
 {
     StepBinding = stepBinding;
     Match = match;
     ExtraArguments = extraArguments;
     StepArgs = stepArgs;
 }
开发者ID:x97mdr,项目名称:SpecFlow,代码行数:7,代码来源:BindingMatch.cs


示例12: RegExpMatch

 internal RegExpMatch(ArrayPrototype parent, Regex regex, Match match, string input) : base(parent, typeof(RegExpMatch))
 {
     this.hydrated = false;
     this.regex = regex;
     this.matches = null;
     this.match = match;
     base.SetMemberValue("input", input);
     base.SetMemberValue("index", match.Index);
     base.SetMemberValue("lastIndex", (match.Length == 0) ? (match.Index + 1) : (match.Index + match.Length));
     string[] groupNames = regex.GetGroupNames();
     int num = 0;
     for (int i = 1; i < groupNames.Length; i++)
     {
         string name = groupNames[i];
         int num3 = regex.GroupNumberFromName(name);
         if (name.Equals(num3.ToString(CultureInfo.InvariantCulture)))
         {
             if (num3 > num)
             {
                 num = num3;
             }
         }
         else
         {
             Group group = match.Groups[name];
             base.SetMemberValue(name, group.Success ? group.ToString() : null);
         }
     }
     this.length = num + 1;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:RegExpMatch.cs


示例13: MacroAttributeEvaluator

        private string MacroAttributeEvaluator(Match m, bool toUnique, Item item)
        {
            var value = m.Groups["attributeValue"].Value.ToString();
            var alias = m.Groups["attributeAlias"].Value.ToString();

            if (toUnique){
                int id = 0;
                if (int.TryParse(value, out id))
                {   
                    Tuple<Guid,Guid> reference = PersistenceManager.Default.GetUniqueIdWithType(id);
                    if (reference != null)
                    {
                        value = reference.Item1.ToString();
                        
                        if (this.RegisterNodeDependencies){
                            var provider = ItemProviders.NodeObjectTypes.GetCourierProviderFromNodeObjectType(reference.Item2);

                            if (provider.HasValue)
                                item.Dependencies.Add(value, provider.Value);
                        }
                    }
                }
            }else{
                Guid guid = Guid.Empty;
                if (Guid.TryParse(value, out guid))
                {
                    int id = PersistenceManager.Default.GetNodeId(guid);
                    if (id != 0)
                        value = id.ToString();
                }
            }

            // Get the matched string.
            return alias + "=\"" + value + "\"";
        }
开发者ID:jayvin,项目名称:Courier,代码行数:35,代码来源:MacroResolver.cs


示例14: 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


示例15: LinkEvaluator

        private string LinkEvaluator(Match match, bool prefixLinks)
        {
            string mdUrlTag = match.Groups[0].Value;
            string rawUrl = match.Groups[2].Value;

            //Escpae external URLs
            if (rawUrl.StartsWith("http") || rawUrl.StartsWith("https") || rawUrl.StartsWith("ftp"))
                return mdUrlTag;

            //Escape anchor links
            if (rawUrl.StartsWith("#"))
                return mdUrlTag;

            //Correct internal image links
            if (rawUrl.StartsWith("../images/"))
                return mdUrlTag.Replace("../images/", "images/");

            //Used for main page to correct relative links
            if (prefixLinks)
            {
                string temp = string.Concat("/documentation/", rawUrl);
                mdUrlTag = mdUrlTag.Replace(rawUrl, temp);
            }

            if (rawUrl.EndsWith("index.md"))
                mdUrlTag = mdUrlTag.Replace("/index.md", "/");
            else
                mdUrlTag.TrimEnd('/');

            return mdUrlTag.Replace(rawUrl, rawUrl.EnsureNoDotsInUrl());
        }
开发者ID:nul800sebastiaan,项目名称:OurUmbraco,代码行数:31,代码来源:MarkdownLogic.cs


示例16: FindSubstrings

        public static Match[] FindSubstrings(string source, string matchPattern, bool findAllUnique)
        {
            SortedList uniqueMatches = new SortedList();
            Match[] retArray = null;

            Regex RE = new Regex(matchPattern, RegexOptions.Multiline);
            MatchCollection theMatches = RE.Matches(source);

            if (findAllUnique)
            {
                for (int counter = 0; counter < theMatches.Count; counter++)
                {
                    if (!uniqueMatches.ContainsKey(theMatches[counter].Value))
                    {
                        uniqueMatches.Add(theMatches[counter].Value,
                                          theMatches[counter]);
                    }
                }

                retArray = new Match[uniqueMatches.Count];
                uniqueMatches.Values.CopyTo(retArray, 0);
            }
            else
            {
                retArray = new Match[theMatches.Count];
                theMatches.CopyTo(retArray, 0);
            }

            return (retArray);
        }
开发者ID:peeboo,项目名称:open-media-library,代码行数:30,代码来源:NetFlixDb.cs


示例17: Handle

 public string Handle(string input, Match match, IListener listener)
 {
     var output = ScheduleTicker.Instance.Tasks
         .Where(o => o.DateTime < DateTime.Now.AddDays(2))
         .Aggregate("", (current, task) => current + (task.Description + " at " + task.DateTime.ToShortTimeString() + Environment.NewLine));
     return output.Trim();
 }
开发者ID:taimur38,项目名称:Yaar,代码行数:7,代码来源:ScheduleListCommand.cs


示例18: UrlEscaper

        public static string UrlEscaper(Match match)
        {
            var url = match.Groups["url"].Value;
            var processedUrl = string.Format("/proxy?url={0}", Uri.EscapeDataString(url));

            return processedUrl;
        }
开发者ID:homoluden,项目名称:Mentoring-HTML,代码行数:7,代码来源:HomeController.cs


示例19: ParseMatchForResult

        public ParseStepResult ParseMatchForResult(Match matched)
        {
            var parsed = GetParsedEntities(matched);
            var notParsed = matched.Groups[3].Value;

            return new ParseStepResult(parsed, notParsed);
        }
开发者ID:xackill,项目名称:01-quality,代码行数:7,代码来源:Rule.cs


示例20: Handle

 public string Handle(string input, Match match, IListener listener)
 {
     var text = match.Groups[1].Value;
     //test code
     ToastView.Create(text, "taimur38", false);
     return text;
 }
开发者ID:taimur38,项目名称:Yaar,代码行数:7,代码来源:SayCommand.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RegularExpressions.MatchCollection类代码示例发布时间:2022-05-26
下一篇:
C# RegularExpressions.GroupCollection类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap