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


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

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


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

示例1: Convert

 Convert(
     this C.ICommonCompilerSettingsOSX settings,
     Bam.Core.StringArray commandLine)
 {
     foreach (var path in settings.FrameworkSearchPaths)
     {
         commandLine.Add(System.String.Format("-F{0}", path.ParseAndQuoteIfNecessary()));
     }
     if (!System.String.IsNullOrEmpty(settings.MinimumVersionSupported))
     {
         var minVersionRegEx = new System.Text.RegularExpressions.Regex("^(?<Type>[a-z]+)(?<Version>[0-9.]+)$");
         var match = minVersionRegEx.Match(settings.MinimumVersionSupported);
         if (!match.Groups["Type"].Success)
         {
             throw new Bam.Core.Exception("Unable to extract SDK type from: '{0}'", settings.MinimumVersionSupported);
         }
         if (!match.Groups["Version"].Success)
         {
             throw new Bam.Core.Exception("Unable to extract SDK version from: '{0}'", settings.MinimumVersionSupported);
         }
         commandLine.Add(System.String.Format("-m{0}-version-min={1}",
             match.Groups["Type"].Value,
             match.Groups["Version"].Value));
     }
 }
开发者ID:knocte,项目名称:BuildAMation,代码行数:25,代码来源:ICommonCompilerSettingsOSX.cs

示例2: Parse

        public static IUnaryOperator Parse(ISyntaxNode parent, ref string Input, IRightValue firstOperand)
        {
            string temp = Input;

            Pattern regExPattern =
                "^\\s*" +
                new Group("def", "(\\+|-|!|~|\\*|&)");//|\\("+Provider.type+"\\)

            System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(regExPattern);
            System.Text.RegularExpressions.Match match = regEx.Match(Input);

            if (!match.Success)
            {
                Input = temp;
                return null;
            }

            Input = Input.Remove(0, match.Index + match.Length);

            string Operator = match.Groups["def"].Value;

            switch (Operator)
            {

                default:
                    Input = temp;
                    throw new NotImplementedException();
            }
        }
开发者ID:Thenarden,项目名称:RPCC,代码行数:29,代码来源:IUnaryOperator.cs

示例3: ConvertToDouble

        /// <summary>
        /// Handling label_value_numeric
        /// </summary>
        public static Double ConvertToDouble(string s)
        {
            try
            {
                string result = "";
                System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("[1-9][0-9,.]*");
                var arr = reg.Match(s).Value.Split('.');

                if (arr.Length == 1)
                    result = arr[0];
                else
                    result = arr[0] + "." + arr[1];

                result = result.Trim('.');

                if (String.IsNullOrWhiteSpace(result))
                    return 0;

                return Convert.ToDouble(result);
            }
            catch (Exception ex)
            {
                logger.Info("Error occured in ConvertToDouble for label_value_numeric - "+ex.Message);
                return 0;
            }
        }
开发者ID:iringtools,项目名称:spr_dl,代码行数:29,代码来源:SPRDataLayer.cs

示例4: Brackets

        public Brackets(ISyntaxNode parent, ref string Input)
            : base(parent)
        {
            Pattern regExPattern =
                   "^\\s*" +
                   new Group("def", "\\(");

            System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(regExPattern);
            System.Text.RegularExpressions.Match match = regEx.Match(Input);

            if (!match.Success)
                throw new ParseException();

            Input = Input.Remove(0, match.Index + match.Length);

            this.Operand = IRightValue.Parse(this, ref Input);

            Pattern regExClosePattern =	"^\\s*\\)";

            regEx = new System.Text.RegularExpressions.Regex(regExClosePattern);
            match = regEx.Match(Input);

            if (!match.Success)
                throw new ParseException();
            Input = Input.Remove(0, match.Index + match.Length);
            regExClosePattern = "^\\s*\\)";
        }
开发者ID:Thenarden,项目名称:RPCC,代码行数:27,代码来源:Brackets.cs

示例5: Try

        //────────────────────────────────────────
        public bool Try(string sName, out int nResult)
        {
            nResult = 0;

            int nPrmNameMatchedCount = 0;
            {
                //正規表現
                System.Text.RegularExpressions.Regex regexp =
                    new System.Text.RegularExpressions.Regex(
                        @"p([0-9]+)p",
                        System.Text.RegularExpressions.RegexOptions.IgnoreCase
                        );

                //文字列検索を1回する。
                System.Text.RegularExpressions.Match match = regexp.Match(sName);

                while (match.Success)
                {
                    string sP1pNumber = match.Groups[1].Value;

                    bool bParseSuccessful = int.TryParse(sP1pNumber, out nResult);
                    if (!bParseSuccessful)
                    {
                        return false;
                    }

                    match = match.NextMatch();
                    nPrmNameMatchedCount++;
                }
            }

            return 1 == nPrmNameMatchedCount;
        }
开发者ID:muzudho,项目名称:CSVExE,代码行数:34,代码来源:P1pNameTesterImpl_.cs

示例6: PrintPrettyShaderInfoLog

        private void PrintPrettyShaderInfoLog()
        {
            string[] programLines = this.shaderProgramText.Split('\n');
            string[] log_lines = GL.GetShaderInfoLog(ShaderID).Split('\n');

            // example line:
            // ERROR: 0:36: Use of undeclared identifier 'diffuseMaterial'

            var regex = new System.Text.RegularExpressions.Regex(@"([0-9]+):([0-9]+):");
            var regex2 = new System.Text.RegularExpressions.Regex(@"([0-9]+)\(([0-9]+)\)");

            if (log_lines.Length > 0) {
                Console.WriteLine("-- {0} --",this.shaderName);
            }
            foreach (var line in log_lines) {
                // print log line
                Console.WriteLine(line);

                // try to print the source-line
                var match = regex.Match(line);
                if (!match.Success) {
                    match = regex2.Match (line);
                }
                if (match.Success) {
                    int lineno = int.Parse(match.Groups[2].Value);
                    Console.WriteLine("   > " + programLines[lineno-1]);
                }
            }
        }
开发者ID:EMAGStefanMueller,项目名称:SimpleScene,代码行数:29,代码来源:SSShader.cs

示例7: BibTeXCheck

 bool BibTeXCheck(){
     if(!aux.ContainsKey(".aux") || aux[".aux"] == null) return false;
     var bibcite = new System.Text.RegularExpressions.Regex("\\\\bibcite\\{(.*?)\\}");
     var citation = new System.Text.RegularExpressions.Regex("\\\\citation\\{(.*?)\\}");
     var bibs = new List<string>();
     var cits = new List<string>();
     bool existbibdata = false;
     Encoding[] encs = KanjiEncoding.GuessKajiEncoding(aux[".aux"]);
     Encoding enc;
     if(encs.Length == 0) enc = Encoding.GetEncoding("shift_jis");
     else enc = encs[0];
     using(var fs = new StringReader(enc.GetString(aux[".aux"]))) {
         while(true) {
             string line = fs.ReadLine();
             if(line == null) break;
             if(!existbibdata && line.IndexOf("\\bibdata{") != -1) existbibdata = true;
             var m = bibcite.Match(line);
             if(m.Success) bibs.Add(m.Groups[1].Value);
             m = citation.Match(line);
             if(m.Success) cits.Add(m.Groups[1].Value);
         }
     }
     if(!existbibdata)return false;
     cits.Sort(); cits = new List<string>(cits.Distinct());
     bibs.Sort(); bibs = new List<string>(bibs.Distinct());
     return !(cits.SequenceEqual(bibs));
 }
开发者ID:abenori,项目名称:TeX2img,代码行数:27,代码来源:AnalyzeLaTeXCompile.cs

示例8: GetDefaultDomain

        public static string GetDefaultDomain(string tnsNamePath)
        {
            if (string.IsNullOrEmpty(tnsNamePath)) return "";

            if (File.Exists(tnsNamePath) == false) return "";

            tnsNamePath = tnsNamePath.ToLower();
            if (tnsNamePath.LastIndexOf("tnsnames.ora") < 0) return "";

            string sqlnetora = tnsNamePath.Replace("tnsnames.ora", "sqlnet.ora");

            if (File.Exists(sqlnetora) == false) return "";

            try
            {
                string sqlnet = File.ReadAllText(sqlnetora);

                var reg = new System.Text.RegularExpressions.Regex(@"([#]*)[\t\ ]*NAMES.DEFAULT_DOMAIN\s*=\s*([a-zA-Z0-9_.]+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                var m = reg.Match(sqlnet);
                if (m.Success)
                {
                    if (m.Groups.Count >= 3)
                    {
                        if (m.Groups[1].Value != null && m.Groups[1].Value.IndexOf('#') >= 0) return "";

                        if (m.Groups[2].Value == null) return "";
                        return m.Groups[2].Value.Trim().ToUpper();
                    }
                }
                return "";
            }
            catch { return ""; }
        }
开发者ID:howbigbobo,项目名称:DailyCode,代码行数:34,代码来源:Sqlnetora.cs

示例9: Parse

        /// <summary>
        /// MT4のカラーを表現する文字列をMT4Colorに変換
        /// </summary>
        /// <param name="mt4ColorStr">MT4でColorToStringをした時の文字列</param>
        /// <returns>MT4Color</returns>
        public static MT4Color Parse(string mt4ColorStr)
        {
            //mt4ColorStrがMT4のColorに則っているか
            if (!System.Text.RegularExpressions.Regex.IsMatch(
    mt4ColorStr, @"^[0-9]{1,3},[0-9]{1,3},[0-9]{1,3}$"))
            {
                //則っていなかったら例外をスロー
                throw new FormatException("MT4Color parse error:" + mt4ColorStr);
            }

            //正規表現のインスタンスを作成
            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"^([0-9]{1,3}),([0-9]{1,3}),([0-9]{1,3})$");

            //正規表現を実行
            var match = reg.Match(mt4ColorStr);

            //赤をパース
            int red = int.Parse(match.Groups[1].Value);
            //緑をパース
            int green = int.Parse(match.Groups[2].Value);
            //青をパース
            int blue = int.Parse(match.Groups[3].Value);

            //返す
            return new MT4Color(red, green, blue);
        }
开发者ID:NeecStudentTeam,项目名称:FxClientDLL-CS,代码行数:31,代码来源:MT4Color.cs

示例10: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            ////get the expired cookie
            //System.Web.Security.FormsAuthentication.SignOut();
            ////set the cookie Domain
            //HttpCookie lcookie2 = Context.Response.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName];
            //lcookie2.Domain = Core.Global.CookieDomain;

            OnlineUserBlock.Components.oluMonitor.MemberSignout();
            Session.Clear();
            if (Request.Cookies["sid"] != null || Request.Cookies["sso"] != null)
            {
                Response.Cookies["sid"].Expires = DateTime.Now;
                Response.Cookies["sso"].Expires = DateTime.Now;//单点登录的Cookie
            }

            string url = CY.Utility.Common.RequestUtility.GetCookieValue("CurrentUrl");

            Response.Cookies["CurrentUrl"].Expires = DateTime.Now;//用户访问过的上个页面地址

            System.Text.RegularExpressions.Regex R = new System.Text.RegularExpressions.Regex("(" + url + ")+"); //查找"Abc"

            System.Text.RegularExpressions.Match M = R.Match("Logout.aspx"); //设定要查找的字符串

            if (M.Index > 0 || url.Length <= 4)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "logout", "<script type='text/javascript'>window.location.href='Login.aspx';</script>");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "logout", "<script type='text/javascript'>window.location.href='" + url + "';</script>");
            }
        }
开发者ID:dalinhuang,项目名称:ume-v3,代码行数:33,代码来源:Logout.aspx.cs

示例11: GetTableName

 public string GetTableName(Type entityType)
 {
     var sql = this.Set(entityType).ToString();
     var regex = new System.Text.RegularExpressions.Regex(@"FROM \[dbo\]\.\[(?<table>.*)\] AS");
     var match = regex.Match(sql);
     return match.Groups["table"].Value;
 }
开发者ID:nivethiniyoganantham,项目名称:ContactsManagerSample,代码行数:7,代码来源:ContactsManagerEntities.cs

示例12: createResponse

        private string createResponse(string rawline)
        {
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("(GET )(/)([^ ]+)");
            var result = regex.Match(rawline);
            if (result.Success && result.Groups.Count == 4)
            {
                string command = result.Groups[3].Value;
                string headers = "HTTP/1.1 200 OK\r\n" +
                "Content-Type: text/plain\r\n" +
                "Accept-Ranges: bytes\r\n" +
                "Vary: Accept-Encoding\r\n";
                if (command == "get_server_data")
                {
                    string response = "name=" + Server.instance.config.getString("server_name") + "\nmax_players=" + Server.instance.config.getString("max_players") + "\ngame_port=" + Server.instance.config.getString("game_port") + "\nplayers=" +
                        Server.instance.playerpool.Count;

                    return headers + "Content-Length: " + response.Length + "\r\n\r\n" + response + "\r\n\r\n";
                }
            }
            else
            {
                string headers = "HTTP/1.1 200 OK\r\n" +
                "Content-Type: text/HTML\r\n" +
                "Accept-Ranges: bytes\r\n" +
                "Vary: Accept-Encoding\r\n" +
                "refresh:5;url=http://gta.vdgtech.eu\r\n\r\nThat command is invalid. Redirecting to gta.vdgtech.eu in 5 seconds.\r\n\r\n";
                return headers;
            }
            return null;
        }
开发者ID:andrefsantos,项目名称:gta-iv-multiplayer,代码行数:30,代码来源:HTTPServer.cs

示例13: GetLanguageFromConfluenceClassAttribute

 private string GetLanguageFromConfluenceClassAttribute(HtmlNode node)
 {
     string val = node.GetAttributeValue("class", "");
     var rx = new System.Text.RegularExpressions.Regex(@"brush:\s?(:?.*);");
     var res = rx.Match(val);
     return res.Success ? res.Value : "";
 }
开发者ID:mysticmind,项目名称:reversemarkdown-net,代码行数:7,代码来源:Pre.cs

示例14: isCardID

        public static bool isCardID(string cid)
        {
            string[] aCity = new string[] { null, null, null, null, null, null, null, null, null, null, null, "北京", "天津", "河北", "山西", "内蒙古", null, null, null, null, null, "辽宁", "吉林", "黑龙江", null, null, null, null, null, null, null, "上海", "江苏", "浙江", "安微", "福建", "江西", "山东", null, null, null, "河南", "湖北", "湖南", "广东", "广西", "海南", null, null, null, "重庆", "四川", "贵州", "云南", "西藏", null, null, null, null, null, null, "陕西", "甘肃", "青海", "宁夏", "新疆", null, null, null, null, null, "台湾", null, null, null, null, null, null, null, null, null, "香港", "澳门", null, null, null, null, null, null, null, null, "国外" };
            double iSum = 0;
            string info = "";
            System.Text.RegularExpressions.Regex rg = new System.Text.RegularExpressions.Regex(@"^\d{17}(\d|x)$");
            System.Text.RegularExpressions.Match mc = rg.Match(cid);
            if (!mc.Success)
            {
                return false;
            }
            cid = cid.ToLower();
            cid = cid.Replace("x", "a");
            if (aCity[int.Parse(cid.Substring(0, 2))] == null)
            {
                return false;
            }
            try
            {
                DateTime.Parse(cid.Substring(6, 4) + "-" + cid.Substring(10, 2) + "-" + cid.Substring(12, 2));
            }
            catch
            {
                return false;
            }
            for (int i = 17; i >= 0; i--)
            {
                iSum += (System.Math.Pow(2, i) % 11) * int.Parse(cid[17 - i].ToString(), System.Globalization.NumberStyles.HexNumber);

            }
            if (iSum % 11 != 1)
                return false;
            return true;
            //return(aCity[int.Parse(cid.Substring(0,2))]+","+cid.Substring(6,4)+"-"+cid.Substring(10,2)+"-"+cid.Substring(12,2)+","+(int.Parse(cid.Substring(16,1))%2==1&iexcl;"男":"女"));
        }
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:35,代码来源:clsCard.cs

示例15: GenerateCode

        /// <summary>
        /// Function that builds the contents of the generated file based on the contents of the input file
        /// </summary>
        /// <param name="inputFileContent">Content of the input file</param>
        /// <returns>Generated file as a byte array</returns>
        protected override byte[] GenerateCode(string inputFileContent)
        {

            var mdRegex = new System.Text.RegularExpressions.Regex(@"(\.\w+)\.(?:md|markdown)$");
            var matches = mdRegex.Match(Path.GetFileName(InputFilePath));

            if (matches.Groups.Count > 1)
            {
                try
                {
                    var input = File.ReadAllText(InputFilePath);
                    var md = new MarkdownSharp.Markdown();
                    var output = md.Transform(input);
                    return ConvertToBytes(output);
                }
                catch (Exception exception)
                {
                    GeneratorError(0, exception.Message, 0, 0);
                }
            }
            else
            {
                GeneratorError(0, "The Markdown tool is only for Markdown files with the following filename format: filename.[required_extension].md or filename.[required_extension].markdown", 0, 0);
            }

            return null;
        }
开发者ID:wheelibin,项目名称:Markdown-For-Visual-Studio,代码行数:32,代码来源:Markdown.cs


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