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


C# System.Text.RegularExpressions.Regex.Matches方法代码示例

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


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

示例1: SplitDigit

        private string SplitDigit(string algorithm)
        {
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\b\d*([.]?\d*)?\b");
            var temp = regex.Matches(algorithm);

            int vIndex = 1;
            string v = "var";
            for (int i = 0; i < temp.Count; i++)
            {
                if (string.IsNullOrEmpty(temp[i].Value))
                    continue;

                while (true)
                {
                    v = "var" + vIndex.ToString();
                    var t = Variable.Keys.Where(p => p.Contains(v)).FirstOrDefault();

                    if (t == null)
                        break;

                    vIndex++;
                }
                var r = new System.Text.RegularExpressions.Regex(@"\b"+temp[i][email protected]"\b");
                algorithm = r.Replace(algorithm, v, 1, temp[i].Index);

                Variable.Add(v, double.Parse(temp[i].Value, new System.Globalization.CultureInfo("en-US")));
            }
            return "(" + algorithm + ")";
        }
开发者ID:AlirezaP,项目名称:FormulaEngine.Net,代码行数:29,代码来源:Engine.cs

示例2: Run

        /// <summary>
        /// このクラスでの実行すること。
        /// </summary>
        /// <param name="runChildren"></param>
        public override void Run(bool runChildren)
        {
            System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(@"(\w*)\(([^)]*)\)");

            List<string> list = new List<string>();
            foreach (System.Text.RegularExpressions.Match item in r.Matches(GetText()))
            {
                if (string.IsNullOrEmpty(FunctionName))
                {
                    list.Add(item.Groups[0].Value);
                }
                else
                {
                    if (item.Groups[1].Value == FunctionName)
                    {
                        if (parameterOrder > -1)
                        {
                            var para = item.Value.Replace(FunctionName+"(","").Replace(")","").Split(',').ElementAtOrDefault(parameterOrder);
                            list.Add(para.Trim().Trim(new char[]{'\''}));
                        }
                        else
                        {
                            list.Add(item.Groups[2].Value);
                        }
                    }
                }
            }
            this.RunChildrenForArray(runChildren, list);
        }
开发者ID:kiichi54321,项目名称:Rawler,代码行数:33,代码来源:GetScriptFunction.cs

示例3: Create

        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("KICK"),
                    Or(
                        Object("PLAYER", new ConnectedPlayersObjectSource(), ObjectMatcherSettings.None),
                        SingleWord("MASK"))))
                .Manual("Makes bad people go away.")
                .ProceduralRule((match, actor) =>
                {
                    if (match.ContainsKey("PLAYER"))
                        KickPlayer(match["PLAYER"] as Actor, actor);
                    else
                    {
                        var mask = match["MASK"].ToString();
                        var maskRegex = new System.Text.RegularExpressions.Regex(ProscriptionList.ConvertGlobToRegex(mask), System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                        //Iterate over local copy because kicking modifies ConnectedClients.
                        foreach (var client in new List<Client>(Clients.ConnectedClients))
                        {
                            var netClient = client as NetworkClient;
                            if (netClient != null && netClient.IsLoggedOn && maskRegex.Matches(netClient.IPString).Count > 0)
                            {
                                Core.MarkLocaleForUpdate(client.Player);
                                KickPlayer(client.Player, actor);
                            }
                        }
                    }

                    return PerformResult.Continue;
                });
        }
开发者ID:Reddit-Mud,项目名称:RMUD,代码行数:34,代码来源:Kick.cs

示例4: S

        static void S()
        {
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"^(?>(0[12])*(?=02e))");
            System.Text.RegularExpressions.MatchCollection matches = regex.Matches("01020102e");

            Console.WriteLine();
            int matchCount = 0;
            foreach (System.Text.RegularExpressions.Match match in matches)
            {
                matchCount++;
                Console.WriteLine("Match " + matchCount + ": " + (match.Value == null ? "NULL" : match.Value));
                System.Text.RegularExpressions.GroupCollection groups = match.Groups;
                int groupCount = -1;
                foreach (System.Text.RegularExpressions.Group group in groups)
                {
                    groupCount++;
                    Console.WriteLine("\tGroup " + groupCount + ": " + (group.Value == null ? "NULL" : group.Value));
                    System.Text.RegularExpressions.CaptureCollection captures = group.Captures;
                    int capCount = 0;
                    foreach (System.Text.RegularExpressions.Capture capture in captures)
                    {
                        capCount++;
                        Console.WriteLine("\t\tCapture " + capCount + ": " + (capture.Value == null ? "NULL" : capture.Value));
                    }
                }
            }
        }
开发者ID:power-zhy,项目名称:GeneralRegex,代码行数:27,代码来源:Test.cs

示例5: Refresh

        public static void Refresh()
        {
            _port = 0;
            _portSet = false;
            _instances.Clear();

            ManagementClass mgmtClass = new ManagementClass("Win32_Process");
            foreach (ManagementObject process in mgmtClass.GetInstances())
            {

                string processName = process["Name"].ToString().ToLower();
                if (processName == "msmdsrv.exe")
                {

                    // get the process pid
                    System.UInt32 pid = (System.UInt32)process["ProcessId"];
                    var parentPid = int.Parse(process["ParentProcessId"].ToString());
                    var parentTitle = "";
                    if (parentPid > 0)
                    {
                        parentTitle = Process.GetProcessById(parentPid).MainWindowTitle;
                        if (parentTitle.Length == 0)
                        {
                            // for minimized windows we need to use some Win32 api calls to get the title
                            parentTitle = GetWindowTitle(parentPid);
                        }
                    }
                    // Get the command line - can be null if we don't have permissions
                    // but should have permission for PowerBI msmdsrv as it will have been
                    // launched by the current user.
                    string cmdLine = null;
                    if (process["CommandLine"] != null)
                    {
                        cmdLine = process["CommandLine"].ToString();
                        try
                        {
                            var rex = new System.Text.RegularExpressions.Regex("-s\\s\"(?<path>.*)\"");
                            var m = rex.Matches(cmdLine);
                            if (m.Count == 0) continue;
                            string msmdsrvPath = m[0].Groups["path"].Captures[0].Value;
                            var portFile = string.Format("{0}\\msmdsrv.port.txt", msmdsrvPath);
                            if (System.IO.File.Exists(portFile))
                            {
                                string sPort = System.IO.File.ReadAllText(portFile, Encoding.Unicode);
                                var port = int.Parse(sPort);
                                _port = port;
                                _portSet = true;
                                _instances.Add(new PowerBIInstance(parentTitle, port));
                                Log.Debug("{class} {method} PowerBI found on port: {port}", "PowerBIHelper", "Refresh", _port);
                                continue;
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error("{class} {Method} {Error}", "PowerBIHelper", "Refresh", ex.Message);
                        }
                    }
                }
            }
        }
开发者ID:votrongdao,项目名称:DaxStudio,代码行数:60,代码来源:PowerBIHelper.cs

示例6: Run

        /// <summary>
        /// このクラスでの実行すること。
        /// </summary>
        /// <param name="runChildren"></param>
        public override void Run(bool runChildren)
        {
            System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("<input [^>]*>");
            System.Text.RegularExpressions.Regex r2 = new System.Text.RegularExpressions.Regex(@"(\w)*\s*=\s*"+"\"([^\"]*)\"");

            var p = this.GetAncestorRawler().OfType<Page>();
            if (p.Any() == false)
            {
                ReportManage.ErrReport(this, "上流にPageがありません");
                return;
            }
            var page = p.First();
            List<KeyValue> list = new List<KeyValue>();
            foreach (System.Text.RegularExpressions.Match item in r.Matches(GetText()))
            {
                var dic = GetParameter(item.Value);
                if (dic.ContainsKey("type") && dic["type"] == "hidden")
                {
                    if (dic.ContainsKey("name") && dic.ContainsKey("value"))
                    {
                        page.AddParameter(dic["name"], dic["value"]);
                        list.Add(new KeyValue() { Key = dic["name"], Value = dic["value"] });
                    }
                }

            }
            base.Run(runChildren);
        }
开发者ID:kiichi54321,项目名称:Rawler,代码行数:32,代码来源:AddHiddenInputParameter.cs

示例7: Compare

 /// <summary>
 /// Compare two version strings
 /// </summary>
 /// <returns>1 if the first version is greater than the second version</returns>
 public static int Compare(string Version1, string Version2)
 {
     if (Version1 == null && Version2 == null)
     {
         return 0;
     }
     if (Version1 != null && Version2 == null)
     {
         return 1;
     }
     if (Version1 == null && Version2 != null)
     {
         return -1;
     }
     System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"([\d]+)");
     System.Text.RegularExpressions.MatchCollection m1 = regex.Matches(Version1);
     System.Text.RegularExpressions.MatchCollection m2 = regex.Matches(Version2);
     int min = Math.Min(m1.Count, m2.Count);
     for (int i = 0; i < min; i++)
     {
         if (Convert.ToInt32(m1[i].Value) > Convert.ToInt32(m2[i].Value))
         {
             return 1;
         }
         if (Convert.ToInt32(m1[i].Value) < Convert.ToInt32(m2[i].Value))
         {
             return -1;
         }
     }
     int max = Math.Max(m1.Count, m2.Count);
     for (int i = min; i < max; i++)
     {
         int v1 = (m1.Count < i ? Convert.ToInt32(m1[i].Value) : 0);
         int v2 = (m2.Count < i ? Convert.ToInt32(m2[i].Value) : 0);
         if (v1 > v2)
         {
             return 1;
         }
         if (v1 < v2)
         {
             return -1;
         }
     }
     return 0;
 }
开发者ID:cmdrmcdonald,项目名称:EliteDangerousDataProvider,代码行数:49,代码来源:Versioning.cs

示例8: Run

 /// <summary>
 /// このクラスでの実行すること。
 /// </summary>
 /// <param name="runChildren"></param>
 public override void Run(bool runChildren)
 {
     System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(pattern, regexOption);
     StringBuilder sb = new StringBuilder(GetText());
     foreach (System.Text.RegularExpressions.Match match in regex.Matches(GetText()))
     {
         sb.Replace(match.Value, string.Empty);
     }
     this.SetText(sb.ToString());
     base.Run(runChildren);
 }
开发者ID:kiichi54321,项目名称:Rawler,代码行数:15,代码来源:RemoveWordByRegular.cs

示例9: GetValue

 /// <summary>
 /// 获取批量值
 /// </summary>
 /// <param name="str"></param>
 /// <param name="s"></param>
 /// <param name="e"></param>
 /// <returns></returns>
 public static System.Collections.Generic.List<string> GetValue(string str, string s, string e)
 {
     var rg = new System.Text.RegularExpressions.Regex("(?<=(" + s + "))[.\\s\\S]*?(?=(" + e + "))");
     var mc = rg.Matches(str);
     var aStrings = new System.Collections.Generic.List<string>();
     for (var i = 0; i < mc.Count; i++)
     {
         aStrings.Add(mc[i].Value);
     }
     return aStrings.Count <= 0 ? null : aStrings;
 }
开发者ID:RyanFu,项目名称:A51C1B616A294D4BBD6D3D46FD7F78A7,代码行数:18,代码来源:WatchTVRegex.cs

示例10: DigitsOnly_TextChanged

 private void DigitsOnly_TextChanged(object sender, TextChangedEventArgs e)
 {
     var input = sender as TextBox;
     var regex = new System.Text.RegularExpressions.Regex("[0-9]");
     var value = String.Empty;
     foreach (var item in regex.Matches(input.Text))
         if (value.Length < 4)
             value += item.ToString();
     input.Text = value;
     input.CaretIndex = 99;
 }
开发者ID:jacekk,项目名称:db4o-library,代码行数:11,代码来源:AddPublicationWindow.xaml.cs

示例11: Parse

 public static HashSet<string> Parse()
 {
     var client = new System.Net.WebClient();
     string pac = client.DownloadString(PACuri);
     var RegIP = new System.Text.RegularExpressions.Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b");
     var MatchResult = RegIP.Matches(pac);
     var Hostlist = new HashSet<string>();
     foreach (System.Text.RegularExpressions.Match m in MatchResult)
         if (m.Value != "255.255.255.255" && m.Value != "127.0.0.1")
             Hostlist.Add(m.Value);
     return Hostlist;
 }
开发者ID:aflyhorse,项目名称:MFGwrapper,代码行数:12,代码来源:PACparser.cs

示例12: GetParameter

 private Dictionary<string, string> GetParameter(string input)
 {
     Dictionary<string, string> dic = new Dictionary<string, string>();
     System.Text.RegularExpressions.Regex r2 = new System.Text.RegularExpressions.Regex(@"(\w*)\s*=\s*" + "\"([^\"]*)\"");
     foreach (System.Text.RegularExpressions.Match item in r2.Matches(input))
     {
         string key = item.Groups[1].Value;
         string val = item.Groups[2].Value;
         dic.Add(key, val);
     }
     return dic;
 }
开发者ID:kiichi54321,项目名称:Rawler,代码行数:12,代码来源:AddHiddenInputParameter.cs

示例13: GetPageCount

 /// <summary>
 /// 返回页数
 /// </summary>
 /// <param name="pdfPath">PDF文件地址</param>
 private static int GetPageCount(string pdfPath)
 {
     byte[] buffer = System.IO.File.ReadAllBytes(pdfPath);
     int length = buffer.Length;
     if (buffer == null)
         return -1;
     if (buffer.Length <= 0)
         return -1;
     string pdfText = Encoding.Default.GetString(buffer);
     System.Text.RegularExpressions.Regex rx1 = new System.Text.RegularExpressions.Regex(@"/Type\s*/Page[^s]");
     System.Text.RegularExpressions.MatchCollection matches = rx1.Matches(pdfText);
     return matches.Count;
 }
开发者ID:lamp525,项目名称:DotNet,代码行数:17,代码来源:PSD2swfHelper.cs

示例14: EmailAddressPassesValidation

        public bool EmailAddressPassesValidation(string EmailAddress)
        {
            using (new FunctionLogger(Log))
            {
                string Match = "^[a-zA-Z0-9_.+-][email protected][a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$";
                System.Text.RegularExpressions.Regex EmailAddressRegEx = new System.Text.RegularExpressions.Regex(Match);

                if (EmailAddressRegEx.Matches(EmailAddress).Count > 0)
                    return true;

                return false;
            }
        }
开发者ID:skankydog,项目名称:fido,代码行数:13,代码来源:AuthenticationService.cs

示例15: WebPageLoadedSearchCalled

        private void WebPageLoadedSearchCalled(object sender, WebPage.WebPageArguments args)
        {
            string htmlData = webpage.htmlData;
            if (htmlData != null)
            {
                System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(_regexPattern);
                results = regex.Matches(htmlData);

            }
            if(InfoReady != null)
            {
                InfoReady(this, new InfoReadyEventArgs("info ready"));
            }

               // webpage.WebPageLoaded -= WebPageLoadedSearchCalled;
        }
开发者ID:conradkoh,项目名称:Buddy,代码行数:16,代码来源:TorrentSearcher.cs


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