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


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

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


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

示例1: SetText

 public void SetText(string text)
 {
     Textarea.Text = text;
       var liner = new System.Text.RegularExpressions.Regex("\n");
       lines = liner.Split(text).Length;
       Textarea.Height = 20 * Math.Min(lines+1,7) + 4;
       Height = Textarea.Height + 28;
 }
开发者ID:qbolec,项目名称:Sharedge,代码行数:8,代码来源:TextEntry.cs

示例2: GetArgs

 public static string[] GetArgs(string cmd)
 {
     if (string.IsNullOrEmpty (cmd))
     {
         return new string[] { };
     }
     var strExp = "\".*?\"";
     var cmdStr = new System.Text.RegularExpressions.Regex(strExp).Replace(cmd, m =>
     {
         var r = m.Value.Replace(" ", _space);
         return r;
     });
   return  cmdStr.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
 }
开发者ID:taliu,项目名称:LReader,代码行数:14,代码来源:CommandArgs.cs

示例3: ArgumentParser

        /// <summary>
        ///    Arguments Parser Class.
        ///      --  Parses Command Line Arguments passed to a Command Line application.
        ///      --  Accepts the string array of arguments that was captured by the application
        ///          at startup.
        ///      --  Parameters should be prefixed with one of the following characters ("-",
        ///          "--", "/", ":").
        ///      --  Calling Syntax:  PDX.BTS.DataMaintenanceUtilites.ArgumentParser commandLine = new PDX.BTS.DataMaintenanceUtilities.ArgumentParser(args);
        ///            -  Returns a String Array of the Parameters with the parameter names as
        ///               the array indices.
        ///            -  For example in the resulting array, the value for the Parameter
        ///               "DataPath" (passed as /DataPath=C:\) will be obtained with -
        ///               commandLine["DataPath"].
        ///            -  For Boolean arguments.  To determine if the parameter was passed is -
        ///               "Usage" (passed as /Usage) will be determined by testing -
        ///               if (commandLine["Usage"] == "true")
        /// </summary>
        // Constructor Method
        public ArgumentParser(string[] Args)
        {
            System.Text.RegularExpressions.Regex splitter         = null;
              System.Text.RegularExpressions.Regex remover          = null;
              string                               currentParameter = null;
              string[]                             parameterParts   = null;

              try
              {
            //  Instantiate a String Dictionary Object to hold the parameters that are found.
            _parsedParameters = new System.Collections.Specialized.StringDictionary();

            //  Set the Set of values that will be searched to find the parameter start
            //  identifiers ("-", "--", "/", or ":").
            splitter = new System.Text.RegularExpressions.Regex(@"^-{1,2}|^/|=|:",
                                  System.Text.RegularExpressions.RegexOptions.IgnoreCase |
                                  System.Text.RegularExpressions.RegexOptions.Compiled);

            //  Set the Set of values that will be removed from the Parameters strings ("'", ".*").
            remover = new System.Text.RegularExpressions.Regex(@"^['""]?(.*?)['""]?$",
                                  System.Text.RegularExpressions.RegexOptions.IgnoreCase |
                                  System.Text.RegularExpressions.RegexOptions.Compiled);

            // Valid parameters forms:  {-,/,--}param{ ,=,:}((",')value(",'))
            // Examples:  -param1 value1 --param2 /param3:"Test-:-work"
            //           /param4=happy -param5 '--=nice=--'
            foreach (string currentTextString in Args)
            {
              // Look for new parameters (-,/ or --) and a possible enclosed value (=,:)
              parameterParts = splitter.Split(currentTextString, 3);

              //  Populate the String Dictionary Object with the values in the current parameter.
              switch (parameterParts.Length)
              {
            // Found a value (for the last parameter found (space separator))
            case 1:
              if (currentParameter != null)
              {
                if (!_parsedParameters.ContainsKey(currentParameter))
                {
                  parameterParts[0] = remover.Replace(parameterParts[0], "$1");
                  _parsedParameters.Add(currentParameter, parameterParts[0]);
                }
                currentParameter = null;
              }
              // else Error: no parameter waiting for a value (skipped)
              break;
            // Found just a parameter
            case 2:
              // The last parameter is still waiting.  With no value, set it to true.
              if (currentParameter != null)
              {
                if (!_parsedParameters.ContainsKey(currentParameter))
                {
                  _parsedParameters.Add(currentParameter, "true");
                }
              }
              currentParameter = parameterParts[1];
              //  Exit this case.
              break;
            // Parameter with enclosed value
            case 3:
              // The last parameter is still waiting.  With no value, set it to true.
              if (currentParameter != null)
              {
                if (!_parsedParameters.ContainsKey(currentParameter))
                {
                  _parsedParameters.Add(currentParameter, "true");
                }
              }
              currentParameter = parameterParts[1];
              // Remove possible enclosing characters (",')
              if (!_parsedParameters.ContainsKey(currentParameter))
              {
                parameterParts[2] = remover.Replace(parameterParts[2], "$1");
                _parsedParameters.Add(currentParameter, parameterParts[2]);
              }
              currentParameter = null;
              //  Exit this case.
              break;
              }
            }
//.........这里部分代码省略.........
开发者ID:MitchVan,项目名称:DataMaintenanceUtilities,代码行数:101,代码来源:ArgumentParser.cs

示例4: StringsCanBeSplitUsingRegularExpressions

        public void StringsCanBeSplitUsingRegularExpressions()
        {
            var str = "the:rain:in:spain";
            var regex = new System.Text.RegularExpressions.Regex (":");
            string[] words = regex.Split (str);
            CollectionAssert.AreEqual (new[] { "the","rain","in","spain" }, words, "The way Eliza Doolittle first spoke in 'My Fair Lady' would break anyone's Karma.");

            //A full treatment of regular expressions is beyond the scope
            //of this tutorial. The book "Mastering Regular Expressions"
            //is highly recommended to be on your bookshelf:
            //http://www.amazon.com/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124
        }
开发者ID:joeybronner,项目名称:CsharpNunitKoans,代码行数:12,代码来源:K030_AboutStrings.cs

示例5: btnLoad_Click

        private void btnLoad_Click(object sender, EventArgs e)
        {
            Int64 iCounter = 0;

               string regexCSVSplit = string.Empty;
               regexCSVSplit = ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))";
               regexCSVSplit = @"([^\\x22\\]*(:?:\\.[^\\x22\\]*)*)\\x22,?|([^,]+),?|,";
               System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(regexCSVSplit);
               string tableName = "MaxMindData";
               string cityPartition = "Cities";
               string blockPartition = "IPBlocks";
               this.Cursor = Cursors.WaitCursor;
               System.IO.StreamReader file =   new System.IO.StreamReader(txtCityFile.Text);
               string inputString = string.Empty;
               AzureTableStorage ats = new AzureTableStorage(txtAccount.Text, txtEndpoint.Text, txtSharedKey.Text, "SharedKey");
               StringBuilder sb = new StringBuilder();
               sb.AppendFormat(@"<?xml version=""1.0"" encoding=""utf-8"" ?>
            <entry xml:base=""http://finseldemos.table.core.windows.net/"" xmlns:d=""http://schemas.microsoft.com/ado/2007/08/dataservices""
             xmlns:m=""http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"" xmlns=""http://www.w3.org/2005/Atom"">");
               int entityCount = 0;
               ats.Tables(cmdType.post, tableName);
               inputString = file.ReadLine(); // read copyright
               inputString = file.ReadLine(); // read column headers
               azureHelper ah = new azureHelper(ats.auth);
               while ((inputString = file.ReadLine()) != null)
               {
            iCounter++;

            string[] dataSet = r.Split(inputString);
            for (int i = 0; i < dataSet.GetUpperBound(0); i++)
             dataSet[i] = dataSet[i].ToString().Replace("\"", "");
            if ((iCounter % 100) == 0)
            {
             Notify(string.Format("Processing location {0}: {1}", iCounter, DateTime.Now.ToString("O")));
            }
            //locId,country,region,city,postalCode,latitude,longitude,metroCode,areaCode
               // string ds = string.Format(locationTemplate, tableName, cityPartition, dataSet[0], inputString);
            sb.AppendFormat(locationTemplate, dataSet);
            entityCount++;
            if (entityCount >= 99)
            {
             sb.Append("</entry>");
            // Notify(string.Format("Transmitting Group of transactions, processed through {0}",iCounter));
             ah.entityGroupTransaction(cmdType.post , tableName, sb.ToString());
             sb = new StringBuilder();
             sb.AppendFormat(@"<?xml version=""1.0"" encoding=""utf-8"" ?>
            <entry xml:base=""http://finseldemos.table.core.windows.net/"" xmlns:d=""http://schemas.microsoft.com/ado/2007/08/dataservices""
             xmlns:m=""http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"" xmlns=""http://www.w3.org/2005/Atom"">");
             entityCount = 0;
            }
            if ((iCounter % 100)==0)
             Application.DoEvents();
               }
               if (entityCount > 0)
               {
            Notify("Transmitting Final Group of transactions");
            sb.Append("</entry>");
            ah.entityGroupTransaction(cmdType.post, tableName, sb.ToString());
            sb = new StringBuilder();
            entityCount = 0;
               }
               file.Close();

               sb = new StringBuilder();
               iCounter = 0;
               sb.AppendFormat(@"<?xml version=""1.0"" encoding=""utf-8"" ?>
            <entry xml:base=""http://finseldemos.table.core.windows.net/"" xmlns:d=""http://schemas.microsoft.com/ado/2007/08/dataservices""
             xmlns:m=""http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"" xmlns=""http://www.w3.org/2005/Atom"">");
               entityCount = 0;
               file = new System.IO.StreamReader(txtBlocksFile.Text);
               inputString = string.Empty;
               inputString = file.ReadLine(); // read copyright
               inputString = file.ReadLine(); // read column headers
               Int64 ipLoadRecord = 0;
               while ((inputString = file.ReadLine()) != null)
               {
            iCounter++;

            string[] dataSet = r.Split(inputString);
            for (int i = 0; i < dataSet.GetUpperBound(0); i++)
             dataSet[i] = dataSet[i].ToString().Replace("\"", "");
            if ((iCounter % 100) == 0)
            {
             Notify(string.Format("Processing location {0}: {1}", iCounter, DateTime.Now.ToString("O")));
            }
            sb.AppendFormat(ipTemplate, dataSet);
            entityCount++;
            if (entityCount >= 500)
            {
             sb.Append("</entry>");
              Notify(string.Format("Transmitting Group of transactions, processed through {0}",iCounter));
             ah.entityGroupTransaction(cmdType.post, tableName, sb.ToString());
             sb = new StringBuilder();
             sb.AppendFormat(@"<?xml version=""1.0"" encoding=""utf-8"" ?>
            <entry xml:base=""http://finseldemos.table.core.windows.net/"" xmlns:d=""http://schemas.microsoft.com/ado/2007/08/dataservices""
             xmlns:m=""http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"" xmlns=""http://www.w3.org/2005/Atom"">");
             entityCount = 0;
            }
            if ((iCounter % 100) == 0)
            {
//.........这里部分代码省略.........
开发者ID:CarpDeus,项目名称:Azure-Commands,代码行数:101,代码来源:Form1.cs

示例6: openItem_ItemClick

 /**
  * Description:
  *  + Open file
  *
  */
 private void openItem_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e)
 {
     StringBuilder imagePath = null;
     var openFile = new OpenFileDialog()
     {
         Title = "Open File Map",
         Multiselect = false,
         Filter = "Data file (.csv) |*.csv|All files (*.*)|*.*"
     };
     var _Result = openFile.ShowDialog();
     if (_Result == true)
     {
         if (openFile.CheckFileExists)
         {
             this.getListImagePath();
             imagePath = new StringBuilder(openFile.FileName);
             System.IO.StreamReader readerFile = new System.IO.StreamReader(imagePath.ToString());
             Image img;
             Rectangle rec;
             String data;
             String[] result;
             String iD;
             String imgPath;
             String imgID;
             int posCenterX;
             int posCenterY;
             int height;
             int width;
             System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex("\t",
                                               System.Text.RegularExpressions.RegexOptions.IgnoreCase);
             //readerFile.ReadLine();
             while ((data = readerFile.ReadLine()) != null)
             {
                 result = rgx.Split(data);
                 if (result.Length >= 4)
                 {
                     iD = result[0];
                     imgID = result[1];
                     if (int.Parse(imgID.Trim()) > 700 && int.Parse(imgID.Trim()) <= 800)
                     {
                         posCenterX = int.Parse(result[2]);
                         posCenterY = int.Parse(result[3]);
                         height = int.Parse(result[4]);
                         width = int.Parse(result[5]);
                         rec = new Rectangle()
                         {
                             Height = height,
                             Width = width,
                             Tag = imgID,
                             StrokeThickness = 2,
                             Stroke = Brushes.White,
                             Fill = new SolidColorBrush()
                         };
                         this.drawRectangleToCanvas(rec, posCenterX - rec.Width / 2, cvMap.Height - (rec.Height / 2 + posCenterY));
                     }
                     else
                     {
                         imgPath = listImagePath[imgID];
                         img = this.createImage(new BitmapImage(new Uri(imgPath, UriKind.RelativeOrAbsolute)));
                         img.Tag = imgID;
                         posCenterX = int.Parse(result[2]);
                         posCenterY = int.Parse(result[3]);
                         this.drawImageToCanvas(img, posCenterX - img.Source.Width / 2, cvMap.Height - (img.Source.Height / 2 + posCenterY));
                     }
                 }
             }
         }
     }
 }
开发者ID:caontfuky,项目名称:map-editor-vs1,代码行数:74,代码来源:MainWindow.xaml.cs

示例7: getListImagePath

 /**
  *
  *
  */
 private void getListImagePath()
 {
     String filePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                                                              @"File\Config.csv");
     //String filePath = "pack://application:,,,/Mapeditor;component/File/Config.csv";
     listImagePath = new Dictionary<string, string>();
     System.IO.StreamReader readerFile = new System.IO.StreamReader(filePath);
     String data;
     String[] result;
     String imgID;
     String imgPath;
     System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex("\t",
                                       System.Text.RegularExpressions.RegexOptions.IgnoreCase);
     readerFile.ReadLine();
     while ((data = readerFile.ReadLine()) != null)
     {
         result = rgx.Split(data);
         if (result.Length >= 2)
         {
             imgID = result[0];
             imgPath = result[1];
             listImagePath.Add(imgID, imgPath);
         }
     }
 }
开发者ID:caontfuky,项目名称:map-editor-vs1,代码行数:29,代码来源:MainWindow.xaml.cs

示例8: Compare

        // Using the Compare function of IComparer
        public int Compare(object x, object y)
        {
            // Cast the objects to ListViewItems
            ListViewItem lvi1 = (ListViewItem)x;
            ListViewItem lvi2 = (ListViewItem)y;

            //try to convert to intervals first
            double first;
            double second;
            System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("(^[<(]\\d+[;]\\d+[>)]$)");
            System.Text.RegularExpressions.Regex r1 = new System.Text.RegularExpressions.Regex("[<>();]");
            if ((r.IsMatch(lvi1.SubItems[column].Text)) && (r.IsMatch(lvi2.SubItems[column].Text)))
            {
                //hooray, an interval
                string[] numbers = r1.Split(lvi1.SubItems[column].Text);
                string[] numbers1 = r1.Split(lvi2.SubItems[column].Text);
                if ((numbers.Length > 1) && (numbers1.Length > 1) && (Double.TryParse(numbers[1], out first)) && (Double.TryParse(numbers1[1], out second)))
                {
                    if (bAscending)
                        return first > second ? 1 : (first < second ? -1 : 0);

                    // Return the negated Compare
                    return first > second ? -1 : (first < second ? 1 : 0);
                }
                else
                {
                    //some strange string, this should not happen
                    //if nothing works, it is a string
                    string lvi1String = lvi1.SubItems[column].ToString();
                    string lvi2String = lvi2.SubItems[column].ToString();

                    // Return the normal Compare
                    if (bAscending)
                        return String.Compare(lvi1String, lvi2String);

                    // Return the negated Compare
                    return -String.Compare(lvi1String, lvi2String);
                }
            }
            else if ((Double.TryParse(lvi1.SubItems[column].Text, out first)) && (Double.TryParse(lvi2.SubItems[column].Text, out second)))
            {
                //it is double
                if (bAscending)
                    return first > second ? 1 : (first < second ? -1 : 0);

                // Return the negated Compare
                return first > second ? -1 : (first < second ? 1 : 0);
            }
            else
            {
                //if nothing works, it is a string
                string lvi1String = lvi1.SubItems[column].ToString();
                string lvi2String = lvi2.SubItems[column].ToString();

                // Return the normal Compare
                if (bAscending)
                    return String.Compare(lvi1String, lvi2String);

                // Return the negated Compare
                return -String.Compare(lvi1String, lvi2String);
            }
              //  return 1;
        }
开发者ID:BackupTheBerlios,项目名称:ferdadataminer-svn,代码行数:64,代码来源:ListViewItemComparer.cs

示例9: rfc2047decode

        /// <summary>
        /// rfc 2047 header body decoding
        /// </summary>
        /// <param name="word"><c>string</c> to decode</param>
        /// <returns>the decoded <see cref="System.String" /></returns>
        public static System.String rfc2047decode( System.String word )
        {
            System.String[] words;
            System.String[] wordetails;

            System.Text.RegularExpressions.Regex rfc2047format = new System.Text.RegularExpressions.Regex (@"(=\?[\-a-zA-Z0-9]+\?[qQbB]\?[a-zA-Z0-9=_\-\.$%&/\'\\!:;{}\+\*\|@#~`^]+\?=)\s*", System.Text.RegularExpressions.RegexOptions.ECMAScript);
            // No rfc2047 format
            if ( !rfc2047format.IsMatch (word) ){
            #if LOG
                if ( log.IsDebugEnabled )
                    log.Debug ("Not a RFC 2047 string: " + word);
            #endif
                return word;
            }
            #if LOG
            if ( log.IsDebugEnabled )
                log.Debug ("Decoding 2047 string: " + word);
            #endif
            words = rfc2047format.Split ( word );
            word = System.String.Empty;
            rfc2047format = new System.Text.RegularExpressions.Regex (@"=\?([\-a-zA-Z0-9]+)\?([qQbB])\?([a-zA-Z0-9=_\-\.$%&/\'\\!:;{}\+\*\|@#~`^]+)\?=", System.Text.RegularExpressions.RegexOptions.ECMAScript);
            for ( int i=0; i<words.GetLength (0); i++ ) {
                if ( !rfc2047format.IsMatch (words[i]) ){
                    word += words[i];
                    continue;
                }
                wordetails = rfc2047format.Split ( words[i] );

                switch (wordetails[2]) {
                    case "q":
                    case "Q":
                        word += anmar.SharpMimeTools.SharpMimeTools.QuotedPrintable2Unicode ( wordetails[1], wordetails[3] ).Replace ('_', ' ');;
                        break;
                    case "b":
                    case "B":
                        try {
                            System.Text.Encoding enc = System.Text.Encoding.GetEncoding (wordetails[1]);
                            System.Byte[] ch = System.Convert.FromBase64String(wordetails[3]);
                            word += enc.GetString (ch);
                        } catch ( System.Exception ) {
                        }
                        break;
                }
            }
            #if LOG
            if ( log.IsDebugEnabled )
                log.Debug ("Decoded 2047 string: " + word);
            #endif
            return word;
        }
开发者ID:jeske,项目名称:StepsDB-alpha,代码行数:55,代码来源:SharpMimeTools.cs

示例10: LoadIcons

        /// <summary>
        /// Loads the icons for the application
        /// </summary>
        /// <remarks>
        /// Sometimes, the program path can change and at this time, no icons
        /// are present
        /// </remarks>
        private void LoadIcons()
        {
            System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("(\\\\)");
            string[] s = r.Split(this.path);
            string newPath = "";
            for (int j = 0; j < s.GetLength(0) - 3; j++)
            {
                newPath = newPath + s[j];
            }

            Icon i;
            iconProvider = new Dictionary<string, Icon>();

            //loading the program icon
            i = new Icon(newPath + "FerdaFrontEnd.ico");
            iconProvider.Add("FerdaIcon", i);

            i = new Icon(newPath + "\\Icons\\Save project.ico");
            iconProvider.Add("OkIcon", i);

            i = new Icon(newPath + "\\Icons\\Exit.ico");
            iconProvider.Add("CancelIcon", i);

            i = new Icon(newPath + "\\Icons\\New project.ico");
            iconProvider.Add("NewIcon", i);

            i = new Icon(newPath + "\\Icons\\Pack sockets.ico");
            iconProvider.Add("TestIcon", i);
        }
开发者ID:BackupTheBerlios,项目名称:ferdadataminer-svn,代码行数:36,代码来源:ODBCConnectionStringControl.cs

示例11: LoadIcons

        /// <summary>
        /// Loads the icons for the application
        /// </summary>
        /// <remarks>
        /// Sometimes, the program path can change and at this time, no icons
        /// are present
        /// </remarks>
        private void LoadIcons()
        {
            System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("(\\\\)");
            string[] s = r.Split(this.path);
            string newPath = "";

            for (int j = 0; j < s.GetLength(0) - 3; j++)
            {
                newPath = newPath + s[j];
            }

            Icon i;
            iconProvider = new Dictionary<string, Icon>();

            //loading the program icon
            i = new Icon(newPath + "FerdaFrontEnd.ico");
            iconProvider.Add("FerdaIcon", i);

            i = new Icon(newPath + "\\Icons\\Save project.ico");
            iconProvider.Add("SaveAndQuitIcon", i);

            i = new Icon(newPath + "\\Icons\\Exit.ico");
            iconProvider.Add("QuitWithoutSaveIcon", i);

            i = new Icon(newPath + "\\Icons\\New project.ico");
            iconProvider.Add("NewIcon", i);

            i = new Icon(newPath + "\\Icons\\Delete from Desktop.ico");
            iconProvider.Add("DeleteIcon", i);

            i = new Icon(newPath + "\\Icons\\Layout.ico");
            iconProvider.Add("JoinIcon", i);

            i = new Icon(newPath + "\\Icons\\Rename Icon.ico");
            iconProvider.Add("RenameIcon", i);

            i = new Icon(newPath + "\\Icons\\USerNote.ico");
            iconProvider.Add("EditIcon", i);
        }
开发者ID:BackupTheBerlios,项目名称:ferdadataminer-svn,代码行数:46,代码来源:MainWindow.cs

示例12: GetParaHtml

		public string[] GetParaHtml() // Only used by the articles system
		{
			string startTag = getDsiHtmlTag();
			string endTag = "</dsi:html>";

			System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("\\n\\W*\\n");
			string[] paraAry = r.Split(HtmlTextBox.Text);
			for (int i = 0; i < paraAry.Length; i++)
			{
				if (paraAry[i].Trim().Length == 0)
					paraAry[i] = "";
				else
				{
					paraAry[i] = startTag + Cambro.Web.Helpers.CleanHtml(paraAry[i]) + endTag;
				}
			}
			return paraAry;
		}
开发者ID:davelondon,项目名称:dontstayin,代码行数:18,代码来源:Html.ascx.cs

示例13: fetch_messages

        //*************************************************************

        public static bool fetch_messages(string project_user, string project_password, int projectid)
        {

            // experimental, under construction

            POP3Client.POP3client client = new POP3Client.POP3client(Pop3ReadInputStreamCharByChar);

            string[] SubjectCannotContainStrings = btnet.Util.rePipes.Split(Pop3SubjectCannotContain);
            string[] FromCannotContainStrings = btnet.Util.rePipes.Split(Pop3FromCannotContain);

            //try
            {
                System.Data.DataRow defaults = Bug.get_bug_defaults();

                //int projectid = (int)defaults["pj"];
                int categoryid = (int)defaults["ct"];
                int priorityid = (int)defaults["pr"];
                int statusid = (int)defaults["st"];
                int udfid = (int)defaults["udf"];

                btnet.Util.write_to_log("pop3:" + client.connect(Pop3Server, Pop3Port, Pop3UseSSL));

                btnet.Util.write_to_log("pop3:sending POP3 command USER");
                btnet.Util.write_to_log("pop3:" + client.USER(project_user));

                btnet.Util.write_to_log("pop3:sending POP3 command PASS");
                btnet.Util.write_to_log("pop3:" + client.PASS(project_password));

                btnet.Util.write_to_log("pop3:sending POP3 command STAT");
                btnet.Util.write_to_log("pop3:" + client.STAT());

                btnet.Util.write_to_log("pop3:sending POP3 command LIST");
                string list;
                list = client.LIST();
                btnet.Util.write_to_log("pop3:list follows:");
                btnet.Util.write_to_log(list);

                string[] messages = null;
                System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("\r\n");
                messages = regex.Split(list);

                int end = messages.Length - 1;

                // loop through the messages
                for (int i = 1; i < end; i++)
                {
                    int space_pos = messages[i].IndexOf(" ");
                    int message_number = Convert.ToInt32(messages[i].Substring(0, space_pos));
                    string message_raw_string = client.RETR(message_number);

                    if (Pop3WriteRawMessagesToLog)
                    {
                        btnet.Util.write_to_log("raw email message:");
                        btnet.Util.write_to_log(message_raw_string);
                    }

                    SharpMimeMessage mime_message = MyMime.get_sharp_mime_message(message_raw_string);

                    string from_addr = MyMime.get_from_addr(mime_message);
                    string subject = MyMime.get_subject(mime_message);


                    if (Pop3SubjectMustContain != "" && subject.IndexOf(Pop3SubjectMustContain) < 0)
                    {
                        btnet.Util.write_to_log("skipping because subject does not contain: " + Pop3SubjectMustContain);
                        continue;
                    }

                    bool bSkip = false;

                    for (int k = 0; k < SubjectCannotContainStrings.Length; k++)
                    {
                        if (SubjectCannotContainStrings[k] != "")
                        {
                            if (subject.IndexOf(SubjectCannotContainStrings[k]) >= 0)
                            {
                                btnet.Util.write_to_log("skipping because subject cannot contain: " + SubjectCannotContainStrings[k]);
                                bSkip = true;
                                break;  // done checking, skip this message
                            }
                        }
                    }

                    if (bSkip)
                    {
                        continue;
                    }

                    if (Pop3FromMustContain != "" && from_addr.IndexOf(Pop3FromMustContain) < 0)
                    {
                        btnet.Util.write_to_log("skipping because from does not contain: " + Pop3FromMustContain);
                        continue; // that is, skip to next message
                    }

                    for (int k = 0; k < FromCannotContainStrings.Length; k++)
                    {
                        if (FromCannotContainStrings[k] != "")
                        {
//.........这里部分代码省略.........
开发者ID:cliffordcan,项目名称:newWebsite,代码行数:101,代码来源:pop3.cs

示例14: rfc2047decode

        /// <summary>
        /// rfc 2047 header body decoding
        /// </summary>
        /// <param name="word"><c>string</c> to decode</param>
        /// <returns>the decoded <see cref="System.String" /></returns>
        public static String rfc2047decode(String word)
        {
            String[] words;
            String[] wordetails;

            System.Text.RegularExpressions.Regex rfc2047format = new System.Text.RegularExpressions.Regex(@"(=\?[\-a-zA-Z0-9]+\?[qQbB]\?[a-zA-Z0-9=_\-\.$%&/\'\\!:;{}\+\*\|@#~`^\(\)]+\?=)\s*", System.Text.RegularExpressions.RegexOptions.ECMAScript);
            // No rfc2047 format
            if (!rfc2047format.IsMatch(word))
            {
                return word;
            }
            words = rfc2047format.Split(word);
            word = String.Empty;
            rfc2047format = new System.Text.RegularExpressions.Regex(@"=\?([\-a-zA-Z0-9]+)\?([qQbB])\?([a-zA-Z0-9=_\-\.$%&/\'\\!:;{}\+\*\|@#~`^\(\)]+)\?=", System.Text.RegularExpressions.RegexOptions.ECMAScript);
            for (int i = 0; i < words.GetLength(0); i++)
            {
                if (!rfc2047format.IsMatch(words[i]))
                {
                    word += words[i];
                    continue;
                }
                wordetails = rfc2047format.Split(words[i]);

                switch (wordetails[2])
                {
                    case "q":
                    case "Q":
                        word += anmar.SharpMimeTools.SharpMimeTools.QuotedPrintable2Unicode(wordetails[1], wordetails[3]).Replace('_', ' ');
                        ;
                        break;
                    case "b":
                    case "B":
                        try
                        {
                            Encoding enc = Encoding.GetEncoding(wordetails[1]);
                            Byte[] ch = Convert.FromBase64String(wordetails[3]);
                            word += enc.GetString(ch);
                        }
                        catch (Exception e)
                        {
                            Trace.Fail(e.Message, e.StackTrace);
                        }
                        break;
                    default:
                        break;
                }
            }
            return word;
        }
开发者ID:smadep,项目名称:MimeTools.NET,代码行数:54,代码来源:SharpMimeTools.cs

示例15: ANTFS_SetPasskey

        /// <summary>
        /// Sets the Passkey
        /// </summary>
        /// <param name="passkey">Passkey as a string</param>
        /// <returns>FS Response</returns>
        public byte ANTFS_SetPasskey(string passkey)
        {
            responseBuf.Clear();

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(",");
            String[] DataArray = regex.Split(passkey);
            int arraylength = DataArray.Length;
            byte[] passkeybytes = new byte[16];

            for (int i = 0; i < arraylength; i++)
                passkeybytes[i] = System.Convert.ToByte(DataArray[i], 16);

            writeRawMessageToDevice(0xE2, new byte[] {0x34,0x01,passkeybytes[0],passkeybytes[1],passkeybytes[2],passkeybytes[3],passkeybytes[4],passkeybytes[5],passkeybytes[6],
                                                            passkeybytes[7],passkeybytes[8],passkeybytes[9],passkeybytes[10],passkeybytes[11],passkeybytes[12],passkeybytes[13],passkeybytes[14],passkeybytes[15]});
            return waitForMsg(new byte[] { 0xE0, 0x00, 0xE2, 0x34 })[0];
        }
开发者ID:Cycli,项目名称:Cycli,代码行数:21,代码来源:ANT_IntegratedANTFSClient.cs


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