title: Kivy Text Filtering Explanation Needed
body: <p>I am a beginner in Python/Kivy and I am trying to build a calculator app using this. When reading about the Text Filtering in the Kivy Documentation, I ran into some problems:</p>
  <p>As quoted on the documentation, this is the code you should used to to accept only float numbers as input(the comments are the things I think that line of code would do):</p>
  <pre><code>class FloatInput(TextInput):
  
  pat = re.compile('[^0-9]')                  # Initiate the regex code
  def insert_text(self, substring, from_undo=False):
      pat = self.pat                          # Call in the regex part
      if '.' in self.text:                    # I dont really understand this 
          s = re.sub(pat, '', substring)
      else:
          s = '.'.join([re.sub(pat, '', s) for s in substring.split('.', 1)])      # I do not really understand this
      return super(FloatInput, self).insert_text(s, from_undo=from_undo)
  </code></pre>
  <p>However, I still do not understand how can this piece of code can work. I have some basic knowledge in Regex if that helps. Can you please explain what this class does for me? Also, how can I follow this example to write some more complicated filtering in the future? For example, if I want to accept only Roman Numbers, how can I do this?</p>
  <p>Thank you so much for any of your help.</p>