<str> = <Match>.group() # Returns the whole match. Also group(0).
<str> = <Match>.group() # Returns the whole match. Also group(0).
<str> = <Match>.group(1) # Returns the part inside first brackets.
<str> = <Match>.group(1) # Returns part inside the first brackets.
<tuple> = <Match>.groups() # Returns all bracketed parts.
<tuple> = <Match>.groups() # Returns all bracketed parts.
<int> = <Match>.start() # Returns start index of the match.
<int> = <Match>.start() # Returns start index of the match.
<int> = <Match>.end() # Returns exclusive end index of the match.
<int> = <Match>.end() # Returns exclusive end index of the match.
@ -378,13 +378,13 @@ import re
### Special Sequences
### Special Sequences
```python
```python
'\d' == '[0-9]' # Matches decimal characters.
'\w' == '[a-zA-Z0-9_]' # Matches alphanumerics and underscore.
'\s' == '[ \t\n\r\f\v]' # Matches whitespaces.
'\d' == '[0-9]' # Also [०-९…]. Matches a decimal character.
'\w' == '[a-zA-Z0-9_]' # Also [ª²³…]. Matches an alphanumeric or _.
'\s' == '[ \t\n\r\f\v]' # Also [\x1c-\x1f…]. Matches a whitespace.
```
```
* **By default, decimal characters, alphanumerics and whitespaces from all alphabets are matched unless `'flags=re.ASCII'` argument is used.**
* **By default, decimal characters, alphanumerics and whitespaces from all alphabets are matched unless `'flags=re.ASCII'` argument is used.**
* **As shown above, it restricts all special sequence matches to the first 128 characters and prevents `'\s'` from accepting `'[\x1c-\x1f]'` (the so-called separator characters).**
* **It restricts special sequence matches to `'[\x00-\x7f]'` (the first 128 characters) and also prevents `'\s'` from accepting `'[\x1c-\x1f]'` (the so-called separator characters).**
* **Use a capital letter for negation (all non-ASCII characters will be matched when used in combination with ASCII flag).**
* **Use a capital letter for negation (all non-ASCII characters will be matched when used in combination with ASCII flag).**
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'re.compile(<regex>)'</span></code> returns a Pattern object with listed methods.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'re.compile(<regex>)'</span></code> returns a Pattern object with listed methods.</strong></li>
</ul>
</ul>
<div><h3id="matchobject">Match Object</h3><pre><codeclass="python language-python hljs"><str> = <Match>.group() <spanclass="hljs-comment"># Returns the whole match. Also group(0).</span>
<div><h3id="matchobject">Match Object</h3><pre><codeclass="python language-python hljs"><str> = <Match>.group() <spanclass="hljs-comment"># Returns the whole match. Also group(0).</span>
<str> = <Match>.group(<spanclass="hljs-number">1</span>) <spanclass="hljs-comment"># Returns the part inside first brackets.</span>
<str> = <Match>.group(<spanclass="hljs-number">1</span>) <spanclass="hljs-comment"># Returns part inside the first brackets.</span>
<tuple> = <Match>.groups() <spanclass="hljs-comment"># Returns all bracketed parts.</span>
<tuple> = <Match>.groups() <spanclass="hljs-comment"># Returns all bracketed parts.</span>
<int> = <Match>.start() <spanclass="hljs-comment"># Returns start index of the match.</span>
<int> = <Match>.start() <spanclass="hljs-comment"># Returns start index of the match.</span>
<int> = <Match>.end() <spanclass="hljs-comment"># Returns exclusive end index of the match.</span>
<int> = <Match>.end() <spanclass="hljs-comment"># Returns exclusive end index of the match.</span>
<div><h3id="specialsequences">Special Sequences</h3><pre><codeclass="python language-python hljs"><spanclass="hljs-string">'\d'</span> == <spanclass="hljs-string">'[0-9]'</span><spanclass="hljs-comment"># Also [०-९…]. Matches a decimal character.</span>
<spanclass="hljs-string">'\w'</span> == <spanclass="hljs-string">'[a-zA-Z0-9_]'</span><spanclass="hljs-comment"># Also [ª²³…]. Matches an alphanumeric or _.</span>
<spanclass="hljs-string">'\s'</span> == <spanclass="hljs-string">'[ \t\n\r\f\v]'</span><spanclass="hljs-comment"># Also [\x1c-\x1f…]. Matches a whitespace.</span>
</code></pre></div>
</code></pre></div>
<ul>
<ul>
<li><strong>By default, decimal characters, alphanumerics and whitespaces from all alphabets are matched unless <codeclass="python hljs"><spanclass="hljs-string">'flags=re.ASCII'</span></code> argument is used.</strong></li>
<li><strong>By default, decimal characters, alphanumerics and whitespaces from all alphabets are matched unless <codeclass="python hljs"><spanclass="hljs-string">'flags=re.ASCII'</span></code> argument is used.</strong></li>
<li><strong>As shown above, it restricts all special sequence matches to the first 128 characters and prevents <codeclass="python hljs"><spanclass="hljs-string">'\s'</span></code> from accepting <codeclass="python hljs"><spanclass="hljs-string">'[\x1c-\x1f]'</span></code> (the so-called separator characters).</strong></li>
<li><strong>It restricts special sequence matches to <codeclass="python hljs"><spanclass="hljs-string">'[\x00-\x7f]'</span></code> (the first 128 characters) and also prevents <codeclass="python hljs"><spanclass="hljs-string">'\s'</span></code> from accepting <codeclass="python hljs"><spanclass="hljs-string">'[\x1c-\x1f]'</span></code> (the so-called separator characters).</strong></li>
<li><strong>Use a capital letter for negation (all non-ASCII characters will be matched when used in combination with ASCII flag).</strong></li>
<li><strong>Use a capital letter for negation (all non-ASCII characters will be matched when used in combination with ASCII flag).</strong></li>
</ul>
</ul>
<div><h2id="format"><ahref="#format"name="format">#</a>Format</h2><pre><codeclass="python hljs"><str> = <spanclass="hljs-string">f'<spanclass="hljs-subst">{<el_1>}</span>, <spanclass="hljs-subst">{<el_2>}</span>'</span><spanclass="hljs-comment"># Curly brackets can also contain expressions.</span>
<div><h2id="format"><ahref="#format"name="format">#</a>Format</h2><pre><codeclass="python hljs"><str> = <spanclass="hljs-string">f'<spanclass="hljs-subst">{<el_1>}</span>, <spanclass="hljs-subst">{<el_2>}</span>'</span><spanclass="hljs-comment"># Curly brackets can also contain expressions.</span>