System.Text.StringBuilder.Remove C# (CSharp) Method

Remove() public method

public Remove ( int startIndex, int length ) : StringBuilder
startIndex int
length int
return StringBuilder
		public StringBuilder Remove (int startIndex, int length)
		{
			// re-ordered to avoid possible integer overflow
			if (startIndex < 0 || length < 0 || startIndex > _length - length)
				throw new ArgumentOutOfRangeException();
			
			if (null != _cached_str)
				InternalEnsureCapacity (_length);
			
			// Copy everything after the 'removed' part to the start 
			// of the removed part and truncate the sLength
			if (_length - (startIndex + length) > 0)
				String.CharCopy (_str, startIndex, _str, startIndex + length, _length - (startIndex + length));

			_length -= length;

			return this;
		}			       

Usage Example

Example #1
1
        static void Main()
        {
            string inputStr = Console.ReadLine();
            string multipleString = "";
            while (inputStr != "END")
            {
                multipleString += inputStr;
                inputStr = Console.ReadLine();
            }
            string pattern = @"(?<=<a).*?\s*href\s*=\s*((""[^""]*""(?=>))|('[^']*'(?=>))|([\w\/\:\.]+\.\w{3})|(\/[^'""]*?(?=>)))";
               //string pattern = @"(?s)(?:<a)(?:[\s\n_0-9a-zA-Z=""()]*?.*?)(?:href([\s\n]*)?=(?:['""\s\n]*)?)([a-zA-Z:#\/._\-0-9!?=^+]*(\([""'a-zA-Z\s.()0-9]*\))?)(?:[\s\na-zA-Z=""()0-9]*.*?)?(?:\>)";
            MatchCollection collection = Regex.Matches(multipleString, pattern);
            List<string> resultStrings = new List<string>();
            foreach (Match match in collection)
            {
                StringBuilder tempStr = new StringBuilder(match.Groups[2].Value);
                if (tempStr[0] == '"' || tempStr[0] == '\'')
                {
                    tempStr.Remove(0,1);
                }
                if (tempStr[tempStr.Length-1] == '"' || tempStr[tempStr.Length-1] == '\'')
                {
                    tempStr.Remove(tempStr.Length-1,1);
                }
                resultStrings.Add(tempStr.ToString());
                Console.WriteLine(tempStr);

            }
            //Console.WriteLine(string.Join("\r\n",resultStrings));
        }
All Usage Examples Of System.Text.StringBuilder::Remove