<li><strong>Also: <codeclass="python hljs"><spanclass="hljs-string">'isspace()'</span></code> checks for <codeclass="python hljs"><spanclass="hljs-string">'[ \t\n\r…]'</span></code>.</strong></li>
</ul>
<div><h2id="regex"><ahref="#regex"name="regex">#</a>Regex</h2><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">import</span> re
<str> = re.sub(<regex>, new, text, count=<spanclass="hljs-number">0</span>) <spanclass="hljs-comment"># Substitutes all occurrences of the pattern.</span>
<list> = re.findall(<regex>, text) <spanclass="hljs-comment"># Returns all occurrences of the pattern.</span>
<str> = re.sub(<regex>, new, text, count=<spanclass="hljs-number">0</span>) <spanclass="hljs-comment"># Substitutes all occurrences with 'new'.</span>
<list> = re.findall(<regex>, text) <spanclass="hljs-comment"># Returns all occurrences as strings.</span>
<list> = re.split(<regex>, text, maxsplit=<spanclass="hljs-number">0</span>) <spanclass="hljs-comment"># Use brackets in regex to keep the matches.</span>
<Match> = re.search(<regex>, text) <spanclass="hljs-comment"># Searches for first occurrence of the pattern.</span>
<Match> = re.match(<regex>, text) <spanclass="hljs-comment"># Searches only at the beginning of the text.</span>