title: clarifications on the re.findall() method in python
body: <p>I wanted to strip a string of punctuation marks and I ended up using </p>
  
  <pre><code>re.findall(r"[\w]+|[^\s\w]", text)
  </code></pre>
  
  <p>It works fine and it does solve my problem. What I don't understand is the details within the parentheses and the whole <em>pattern</em> thing. What does <code>r"[\w]+|[^\s\w]"</code> really mean? I looked it up in the Python standard library and it says:</p>
  
  <pre><code>re.findall(pattern, string, flags=0)
  </code></pre>
  
  <blockquote>
    <p>Return all non-overlapping matches of pattern in string, as a list of
    strings. The string is scanned left-to-right, and matches are returned
    in the order found. If one or more groups are present in the pattern,
    return a list of groups; this will be a list of tuples if the pattern
    has more than one group. Empty matches are included in the result
    unless they touch the beginning of another match.</p>
  </blockquote>
  
  <p>I am not sure if I get this and the clarification sounds a little vague to me. Can anyone please tell me what a pattern in this context means and how exactly it is defined in the findall() method?</p>