SIL.FieldWorks.IText.ConcordanceControl.FirstPassFilterString C# (CSharp) Method

FirstPassFilterString() private method

If we're not matching diacritics, then our first pass has to allow for diacritics in the baseline text, but we can at least filter on all the non-diacritic chars in sequence to maybe eliminate some paragraphs at this initial stage.
private FirstPassFilterString ( string sMatch ) : string
sMatch string
return string
		private string FirstPassFilterString(string sMatch)
		{
			if (m_rbtnUseRegExp.Checked || !m_chkMatchCase.Checked)
				return "%";		// can we do better?
			var sb = new StringBuilder(sMatch);
			if (!m_chkMatchDiacritics.Checked)
			{
				// Allow any number of diacritics (or other chars for that matter, alas) between
				// every nondiacritic character in the string.
				for (int ich = sb.Length - 1; ich > 0; --ich)
				{
					if (Icu.IsDiacritic(sb[ich]))
						sb[ich] = '%';
					else
						sb.Insert(ich, '%');
				}
			}
			// Add beginning and ending wildcards as needed.
			if (m_rbtnAnywhere.Checked || m_rbtnAtEnd.Checked)
				sb.Insert(0, '%');
			if (m_rbtnAnywhere.Checked || m_rbtnAtStart.Checked)
				sb.Append('%');
			// Get rid of any doubled wildcard markers.  Doing this 3 times reduces as many as
			// 8 consecutive markers to a single one.
			sb.Replace("%%", "%");
			sb.Replace("%%", "%");
			sb.Replace("%%", "%");
			// Double single quotes to quote them as part of an SQL string.
			return sb.ToString().Replace("'", "''");
		}