// strip leading chars if it is a punctuation public static string StripLeadChars(string inTerm, string specChars) { string outStrLead = inTerm; int index = 0; while ((index < outStrLead.Length) && (CharUtil.IsSpecifiedChar(outStrLead[index], specChars) == true)) { index++; } if ((index > 0) && (index < outStrLead.Length)) { outStrLead = outStrLead.Substring(index); } return(outStrLead); }
// strip ending chars if it is a punctuation public static string StripEndChars(string inTerm, string specChars) { string outStrEnd = inTerm; int length = outStrEnd.Length; int index = length - 1; while ((index > -1) && (CharUtil.IsSpecifiedChar(outStrEnd[index], specChars) == true)) { index--; } if ((index < length - 1) && (index > -1)) { outStrEnd = outStrEnd.Substring(0, index + 1); } return(outStrEnd); }