removes the specified strings in the string array from the input string : String Array « Data Types « C# / C Sharp






removes the specified strings in the string array from the input string

    
//CruiseControl is open source software and is developed and maintained by a group of dedicated volunteers. 
//CruiseControl is distributed under a BSD-style license.
//http://cruisecontrol.sourceforge.net/
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace ThoughtWorks.CruiseControl.Core.Util
{
    /// <summary>
    /// Class with handy stirng routines
    /// </summary>
    public class StringUtil
    {

        /// <summary>
        /// removes the specified strings in the string array from the input string
        /// </summary>
        /// <param name="input"></param>
        /// <param name="removals"></param>
        /// <returns></returns>
        public static string Strip(string input, params string[] removals)
        {
            string revised = input;
            foreach (string removal in removals)
            {
                int i;
                while ((i = revised.IndexOf(removal)) > -1)
                    revised = revised.Remove(i, removal.Length);
            }

            return revised;
        }
   }
}

   
    
    
    
  








Related examples in the same category

1.Generates a hashcode for the string array
2.Count how many times a word appears in an array of words.
3.Find all unique words in an array of words.
4.Gets an array of sentences from a string.
5.Array To New Line Separated String
6.New Line Separated String To Array
7.returns the elements of the array as a string, delimited with the default delimitor
8.Ensures that a given array can hold up to minCapacity elements.
9.Strings to byte array.
10.String Array To String
11.Processes a string and returns the arguments in an array.
12.Demonstrate string arraysDemonstrate string arrays
13.String To Char ArrayString To Char Array
14.Comparing string to char array