diff --git a/README.md b/README.md index b02c1d3..44b2f5b 100644 --- a/README.md +++ b/README.md @@ -351,8 +351,8 @@ Regex ----- ```python import re -<str> = re.sub(<regex>, new, text, count=0) # Substitutes all occurrences of the pattern. -<list> = re.findall(<regex>, text) # Returns all occurrences of the pattern. +<str> = re.sub(<regex>, new, text, count=0) # Substitutes all occurrences with 'new'. +<list> = re.findall(<regex>, text) # Returns all occurrences as strings. <list> = re.split(<regex>, text, maxsplit=0) # Use brackets in regex to keep the matches. <Match> = re.search(<regex>, text) # Searches for first occurrence of the pattern. <Match> = re.match(<regex>, text) # Searches only at the beginning of the text. diff --git a/index.html b/index.html index f3f97f8..cd7f92e 100644 --- a/index.html +++ b/index.html @@ -457,8 +457,8 @@ to_exclusive = <range>.stop <li><strong>Also: <code class="python hljs"><span class="hljs-string">'isspace()'</span></code> checks for <code class="python hljs"><span class="hljs-string">'[ \t\n\r…]'</span></code>.</strong></li> </ul> <div><h2 id="regex"><a href="#regex" name="regex">#</a>Regex</h2><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> re -<str> = re.sub(<regex>, new, text, count=<span class="hljs-number">0</span>) <span class="hljs-comment"># Substitutes all occurrences of the pattern.</span> -<list> = re.findall(<regex>, text) <span class="hljs-comment"># Returns all occurrences of the pattern.</span> +<str> = re.sub(<regex>, new, text, count=<span class="hljs-number">0</span>) <span class="hljs-comment"># Substitutes all occurrences with 'new'.</span> +<list> = re.findall(<regex>, text) <span class="hljs-comment"># Returns all occurrences as strings.</span> <list> = re.split(<regex>, text, maxsplit=<span class="hljs-number">0</span>) <span class="hljs-comment"># Use brackets in regex to keep the matches.</span> <Match> = re.search(<regex>, text) <span class="hljs-comment"># Searches for first occurrence of the pattern.</span> <Match> = re.match(<regex>, text) <span class="hljs-comment"># Searches only at the beginning of the text.</span>