diff --git a/README.md b/README.md index 195a278..3d97e68 100644 --- a/README.md +++ b/README.md @@ -320,35 +320,33 @@ String = .index() # Same but raises ValueError if missing. ``` -```python - = .isdecimal() # True if str contains only [0-9], [٠-٩], … - = .isdigit() # Also true if str contains '¹²³…'. - = .isnumeric() # Also true if str contains '¼½¾…'. -``` - ```python = .replace(old, new [, count]) # Replaces 'old' with 'new' at most 'count' times. + = .translate() # Use `str.maketrans()` to generate table. = textwrap.wrap(, width) # Nicely breaks string into lines. ``` - * **Also: `'lstrip()'`, `'rstrip()'`.** * **Also: `'lower()'`, `'upper()'`, `'capitalize()'` and `'title()'`.** +### Properties +```text ++---------------+----------+----------+----------+----------+----------+----------+ +| | [\t\n\r] | [ !#$%…] | [A-Za-z] | [¼½¾…] | [¹²³…] | [0-9] | ++---------------+----------+----------+----------+----------+----------+----------+ +| isprintable() | | yes | yes | yes | yes | yes | +| isalnum() | | | yes | yes | yes | yes | +| isnumeric() | | | | yes | yes | yes | +| isdigit() | | | | | yes | yes | +| isdecimal() | | | | | | yes | ++---------------+----------+----------+----------+----------+----------+----------+ +``` + ### Char ```python = chr() # Converts int to unicode char. = ord() # Converts unicode char to int. ``` -```python ->>> ord('0'), ord('9') -(48, 57) ->>> ord('A'), ord('Z') -(65, 90) ->>> ord('a'), ord('z') -(97, 122) -``` - Regex ----- diff --git a/index.html b/index.html index 4544e5d..19628f5 100644 --- a/index.html +++ b/index.html @@ -432,28 +432,29 @@ to_exclusive = <range>.stop <int> = <str>.find(<sub_str>) # Returns start index of first match or -1. <int> = <str>.index(<sub_str>) # Same but raises ValueError if missing. -
<bool> = <str>.isdecimal()                   # True if str contains only [0-9], [٠-٩], …
-<bool> = <str>.isdigit()                     # Also true if str contains '¹²³…'.
-<bool> = <str>.isnumeric()                   # Also true if str contains '¼½¾…'.
-
<str>  = <str>.replace(old, new [, count])   # Replaces 'old' with 'new' at most 'count' times.
+<str>  = <str>.translate(<table>)            # Use `str.maketrans(<dict>)` to generate table.
 <list> = textwrap.wrap(<str>, width)         # Nicely breaks string into lines.
 
  • Also: 'lstrip()', 'rstrip()'.
  • Also: 'lower()', 'upper()', 'capitalize()' and 'title()'.
+

Properties

+---------------+----------+----------+----------+----------+----------+----------+
+|               | [\t\n\r] | [ !#$%…] | [A-Za-z] |  [¼½¾…]  |  [¹²³…]  |  [0-9]   |
++---------------+----------+----------+----------+----------+----------+----------+
+| isprintable() |          |   yes    |   yes    |   yes    |   yes    |   yes    |
+| isalnum()     |          |          |   yes    |   yes    |   yes    |   yes    |
+| isnumeric()   |          |          |          |   yes    |   yes    |   yes    |
+| isdigit()     |          |          |          |          |   yes    |   yes    |
+| isdecimal()   |          |          |          |          |          |   yes    |
++---------------+----------+----------+----------+----------+----------+----------+
+
+

Char

<str> = chr(<int>)                           # Converts int to unicode char.
 <int> = ord(<str>)                           # Converts unicode char to int.
 
-
>>> ord('0'), ord('9')
-(48, 57)
->>> ord('A'), ord('Z')
-(65, 90)
->>> ord('a'), ord('z')
-(97, 122)
-

#Regex

import re
 <str>   = re.sub(<regex>, new, text, count=0)  # Substitutes all occurrences.
 <list>  = re.findall(<regex>, text)            # Returns all occurrences.
diff --git a/web/script_2.js b/web/script_2.js
index ab9da5e..2ba5309 100644
--- a/web/script_2.js
+++ b/web/script_2.js
@@ -205,6 +205,19 @@ const DIAGRAM_11_B =
   '┃     4     │ -2147483648 │    0 │  2147483647 ┃\n' +
   '┗━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━━━━┛\n';
 
+const DIAGRAM_12_A =
+  '+---------------+----------+----------+----------+----------+----------+----------+\n';
+
+const DIAGRAM_12_B =
+  '┏━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┓\n' +
+  '┃               │ [\\t\\n\\r] │ [ !#$%…] │ [A-Za-z] │  [¼½¾…]  │  [¹²³…]  │  [0-9]   ┃\n' +
+  '┠───────────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┨\n' +
+  '┃ isprintable() │          │    ✓     │    ✓     │    ✓     │    ✓     │    ✓     ┃\n' +
+  '┃ isalnum()     │          │          │    ✓     │    ✓     │    ✓     │    ✓     ┃\n' +
+  '┃ isnumeric()   │          │          │          │    ✓     │    ✓     │    ✓     ┃\n' +
+  '┃ isdigit()     │          │          │          │          │    ✓     │    ✓     ┃\n' +
+  '┃ isdecimal()   │          │          │          │          │          │    ✓     ┃\n' +
+  '┗━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━┛\n';
 
 // isFontAvailable:
 (function(d){function c(c){b.style.fontFamily=c;e.appendChild(b);f=b.clientWidth;e.removeChild(b);return f}var f,e=d.body,b=d.createElement("span");b.innerHTML=Array(100).join("wi");b.style.cssText=["position:absolute","width:auto","font-size:128px","left:-99999px"].join(" !important;");var g=c("monospace"),h=c("serif"),k=c("sans-serif");window.isFontAvailable=function(b){return g!==c(b+",monospace")||k!==c(b+",sans-serif")||h!==c(b+",serif")}})(document);
@@ -221,6 +234,7 @@ if (isFontAvailable('Menlo')) {
   $(`code:contains(${DIAGRAM_9_A})`).html(DIAGRAM_9_B);
   $(`code:contains(${DIAGRAM_10_A})`).html(DIAGRAM_10_B);
   $(`code:contains(${DIAGRAM_11_A})`).html(DIAGRAM_11_B);
+  $(`code:contains(${DIAGRAM_12_A})`).html(DIAGRAM_12_B);
 }
 
 var isMobile = false;