# C1.WPF.SpellChecker.C1SpellChecker.CustomParser

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_WPF_SpellChecker_C1SpellChecker_CustomParser_" data-uid="C1.WPF.SpellChecker.C1SpellChecker.CustomParser*">CustomParser Property
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_WPF_SpellChecker_C1SpellChecker_CustomParser_" data-uid="C1.WPF.SpellChecker.C1SpellChecker.CustomParser*"></a>
<h4 id="C1_WPF_SpellChecker_C1SpellChecker_CustomParser" data-uid="C1.WPF.SpellChecker.C1SpellChecker.CustomParser">CustomParser</h4>
<div class="markdown level1 summary"><p>Gets or sets a custom spell-checking parser.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public ISpellParser CustomParser { get; set; }</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Property CustomParser As ISpellParser</code></pre>
</div>
<h5 id="C1_WPF_SpellChecker_C1SpellChecker_CustomParser_remarks">Remarks</h5>
<div class="markdown level1 remarks"><pre><code>&lt;p&gt;This property allows you to specify a custom parser for breaking up 
</code></pre>
<p>text into words to be spell-checked.</p>
<p>For example, you may want to use a custom parser when checking
source code files. This way you can spell-check the comments in the code
and skip the actual code.</p>
</div>
<h5 id="C1_WPF_SpellChecker_C1SpellChecker_CustomParser_examples">Examples</h5>
<p>The class below implements a custom parser that breaks words that contain
underscores or mixed case into separate words. For example, this parser would
treat &quot;Customer_Code&quot; or &quot;CustomerCode&quot; as two separate words.</p>
<pre><code class="lang-csharp">public class Parser : C1.Win.C1SpellChecker.ISpellParser
{
  CharRange ISpellParser.GetNextWord(string text, int start, IgnoreOptions ignore, string previousWord)
  {
    // start with default implementation
    CharRange range = CharRange.GetNextWord(text, start, ignore, previousWord);

    // additional logic to handle underscores and mixed-case
    if (range != null)
    {
      // get original word
      string word = range.Text;

      // split word at underscores
      int index = word.IndexOf('_');
      if (index &gt; -1)
      {
        word = word.Substring(0, index);
        range = new CharRange(word, range.Start, word == previousWord);
      }

      // split MixedCasedWords
      for (int i = 1; i &lt; word.Length; i++)
      {
        if (char.IsUpper(word[i]) &amp;&amp; char.IsLower(word[i - 1]))
        {
          word = word.Substring(0, i);
          range = new CharRange(word, range.Start, word == previousWord);
        }
      }
    }

    // done
    return range;
  }
  string ISpellParser.FilterWord(string word)
  {
    return word;
  }
}</code></pre>

</div>
