Browse Source

Regex, Exceptions

pull/74/merge
Jure Šorn 2 years ago
parent
commit
1d552e4c76
3 changed files with 16 additions and 16 deletions
  1. 12
      README.md
  2. 16
      index.html
  3. 4
      parse.js

12
README.md

@ -378,16 +378,16 @@ import re
```
### Special Sequences
* **By default, decimal characters, alphanumerics and whitespaces from all alphabets are matched unless `'flags=re.ASCII'` argument is used.**
* **As shown below, it restricts special sequence matches to the first 128 characters and 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).**
```python
'\d' == '[0-9]' # Matches decimal characters.
'\w' == '[a-zA-Z0-9_]' # Matches alphanumerics and underscore.
'\s' == '[ \t\n\r\f\v]' # Matches whitespaces.
```
* **By default, decimal characters, alphanumerics and whitespaces from all alphabets are matched unless `'flags=re.ASCII'` argument is used.**
* **As shown above, it restricts special sequence matches to the first 128 characters and 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).**
Format
------
@ -1436,8 +1436,8 @@ BaseException
+-- EOFError # Raised by input() when it hits end-of-file condition.
+-- LookupError # Raised when a look-up on a collection fails.
| +-- IndexError # Raised when a sequence index is out of range.
| +-- KeyError # Raised when a dictionary key or set element is not found.
+-- NameError # Raised when a variable name is not found.
| +-- KeyError # Raised when a dictionary key or set element is missing.
+-- NameError # Raised when an object is missing.
+-- OSError # Errors such as “file not found” or “disk full” (see Open).
| +-- FileNotFoundError # When a file or directory is requested but doesn't exist.
+-- RuntimeError # Raised by errors that don't fall into other categories.

16
index.html

@ -355,16 +355,16 @@ to_exclusive = <range>.stop
&lt;int&gt; = &lt;Match&gt;.end() <span class="hljs-comment"># Returns exclusive end index of the match.</span>
</code></pre></div>
<div><h3 id="specialsequences">Special Sequences</h3><ul>
<li><strong>By default, decimal characters, alphanumerics and whitespaces from all alphabets are matched unless <code class="python hljs"><span class="hljs-string">'flags=re.ASCII'</span></code> argument is used.</strong></li>
<li><strong>As shown below, it restricts special sequence matches to the first 128 characters and prevents <code class="python hljs"><span class="hljs-string">'\s'</span></code> from accepting <code class="python hljs"><span class="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>
</ul><pre><code class="python language-python hljs"><span class="hljs-string">'\d'</span> == <span class="hljs-string">'[0-9]'</span> <span class="hljs-comment"># Matches decimal characters.</span>
<div><h3 id="specialsequences">Special Sequences</h3><pre><code class="python language-python hljs"><span class="hljs-string">'\d'</span> == <span class="hljs-string">'[0-9]'</span> <span class="hljs-comment"># Matches decimal characters.</span>
<span class="hljs-string">'\w'</span> == <span class="hljs-string">'[a-zA-Z0-9_]'</span> <span class="hljs-comment"># Matches alphanumerics and underscore.</span>
<span class="hljs-string">'\s'</span> == <span class="hljs-string">'[ \t\n\r\f\v]'</span> <span class="hljs-comment"># Matches whitespaces.</span>
</code></pre></div>
<ul>
<li><strong>By default, decimal characters, alphanumerics and whitespaces from all alphabets are matched unless <code class="python hljs"><span class="hljs-string">'flags=re.ASCII'</span></code> argument is used.</strong></li>
<li><strong>As shown above, it restricts special sequence matches to the first 128 characters and prevents <code class="python hljs"><span class="hljs-string">'\s'</span></code> from accepting <code class="python hljs"><span class="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>
</ul>
<div><h2 id="format"><a href="#format" name="format">#</a>Format</h2><pre><code class="python language-python hljs">&lt;str&gt; = <span class="hljs-string">f'<span class="hljs-subst">{&lt;el_1&gt;}</span>, <span class="hljs-subst">{&lt;el_2&gt;}</span>'</span>
&lt;str&gt; = <span class="hljs-string">'{}, {}'</span>.format(&lt;el_1&gt;, &lt;el_2&gt;)
</code></pre></div>
@ -1232,8 +1232,8 @@ error_msg = <span class="hljs-string">''</span>.join(traceback.format_exception(
├── EOFError <span class="hljs-comment"># Raised by input() when it hits end-of-file condition.</span>
├── LookupError <span class="hljs-comment"># Raised when a look-up on a collection fails.</span>
│ ├── IndexError <span class="hljs-comment"># Raised when a sequence index is out of range.</span>
│ └── KeyError <span class="hljs-comment"># Raised when a dictionary key or set element is not found.</span>
├── NameError <span class="hljs-comment"># Raised when a variable name is not found.</span>
│ └── KeyError <span class="hljs-comment"># Raised when a dictionary key or set element is missing.</span>
├── NameError <span class="hljs-comment"># Raised when an object is missing.</span>
├── OSError <span class="hljs-comment"># Errors such as “file not found” or “disk full” (see Open).</span>
│ └── FileNotFoundError <span class="hljs-comment"># When a file or directory is requested but doesn't exist.</span>
├── RuntimeError <span class="hljs-comment"># Raised by errors that don't fall into other categories.</span>

4
parse.js

@ -234,8 +234,8 @@ const DIAGRAM_7_B =
" ├── EOFError <span class='hljs-comment'># Raised by input() when it hits end-of-file condition.</span>\n" +
" ├── LookupError <span class='hljs-comment'># Raised when a look-up on a collection fails.</span>\n" +
" │ ├── IndexError <span class='hljs-comment'># Raised when a sequence index is out of range.</span>\n" +
" │ └── KeyError <span class='hljs-comment'># Raised when a dictionary key or set element is not found.</span>\n" +
" ├── NameError <span class='hljs-comment'># Raised when a variable name is not found.</span>\n" +
" │ └── KeyError <span class='hljs-comment'># Raised when a dictionary key or set element is missing.</span>\n" +
" ├── NameError <span class='hljs-comment'># Raised when an object is missing.</span>\n" +
" ├── OSError <span class='hljs-comment'># Errors such as “file not found” or “disk full” (see Open).</span>\n" +
" │ └── FileNotFoundError <span class='hljs-comment'># When a file or directory is requested but doesn't exist.</span>\n" +
" ├── RuntimeError <span class='hljs-comment'># Raised by errors that don't fall into other categories.</span>\n" +

Loading…
Cancel
Save