title: How to search for whole words in a text widget?
body: <p>I am Working on a Python Text Editor With Python and tkinter. But I Have Some Problems with changing font color of the text widget.<br>
  I have just started writing.<br>
  Its been just 5 mins till then.<br>
  <br>
  <strong>Here is editor.py</strong></p>
  <pre><code>##imports
  from tkinter import Tk,Text,BOTH,font
  from font import fontify
  
  ##When the text gets edited
  def Keyboardpress(key):
      editarea_text = editArea.get(&quot;1.0&quot;,&quot;end&quot;)
      ##Calling the fontify function for doing some chill!
      fontify(editArea,editarea_text)
  
  ##Creating Window
  editor = Tk()
  
  ##resizing editor
  editor.geometry(&quot;400x400&quot;)
  
  ##creating a font
  myFont = font.Font(family='Courier',size = 24,weight = &quot;normal&quot;)
  
  ##Here goes the ui
  editArea = Text(editor,bg=&quot;#333&quot;,fg=&quot;#eee&quot;,height = 400,width = 400,font = myFont)
  editArea.bind('&lt;key&gt;',print())
  editArea.pack(fill = BOTH)
  
  ##binding Button press with editor
  editor.bind( '&lt;Key&gt;', lambda i : Keyboardpress(i))
  
  ##Excecuting Window
  editor.mainloop()
  </code></pre>
  <br>
  **And This is font.py**
  <pre><code>keywords = [&quot;False&quot;,&quot;await&quot;,&quot;else&quot;,&quot;import&quot;,&quot;pass&quot;,&quot;None&quot;,&quot;break&quot;,&quot;except&quot;,&quot;in&quot;,&quot;raise&quot;,&quot;True&quot;,&quot;class&quot;,&quot;def&quot;]#and so on
  
  def fontify(self,self_text):
      self.tag_remove('keyword', '1.0', &quot;end&quot;)
  
      for word in keywords:
          idx = '1.0'
          while idx:
              idx = self.search(word, idx, nocase=0, stopindex=&quot;end&quot;)
              if idx:
                  lastidx = '%s+%dc' % (idx, len(word))
                  self.tag_add('keyword', idx, lastidx)
                  idx = lastidx
  
      self.tag_config('keyword', foreground='deeppink')
  </code></pre>
  <p><a href="https://i.stack.imgur.com/u7L3J.png" rel="nofollow noreferrer"><strong>running This Gives me desired output</strong></a></p>
  <p><a href="https://i.stack.imgur.com/M3349.png" rel="nofollow noreferrer"><strong>But how to remove these undesired colored ones</strong></a></p>