From 86fa13022b1f0b09743c27ac1e63c0e7319a589d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 29 Oct 2021 21:57:21 +0200 Subject: [PATCH] String, Regex --- README.md | 8 ++++---- index.html | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e4316ff..abb9364 100644 --- a/README.md +++ b/README.md @@ -308,7 +308,7 @@ String ```python = .split() # Splits on one or more whitespace characters. = .split(sep=None, maxsplit=-1) # Splits on 'sep' str at most 'maxsplit' times. - = .splitlines(keepends=False) # Splits on [\n\r\f\v\x1c\x1d\x1e\x85…] and \r\n. + = .splitlines(keepends=False) # On [\n\r\f\v\x1c-\x1e\x85\u2028\u2029] and \r\n. = .join() # Joins elements using string as a separator. ``` @@ -329,7 +329,7 @@ String = chr() # Converts int to Unicode char. = ord() # Converts Unicode char to int. ``` -* **Also: `'lstrip()'`, `'rstrip()'`.** +* **Also: `'lstrip()'`, `'rstrip()'` and `'rsplit()'`.** * **Also: `'lower()'`, `'upper()'`, `'capitalize()'` and `'title()'`.** ### Property Methods @@ -344,7 +344,7 @@ String | isdecimal() | | | | | yes | +---------------+----------+----------+----------+----------+----------+ ``` -* **Also: `'isspace()'` checks for `'[ \t\n\r\f\v…]'`.** +* **Also: `'isspace()'` checks for `'[ \t\n\r\f\v\x1c-\x1f\x85…]'`.** Regex @@ -377,7 +377,7 @@ 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]'`.** +* **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.** ```python '\d' == '[0-9]' # Matches decimal characters. diff --git a/index.html b/index.html index ce130e4..e1da59e 100644 --- a/index.html +++ b/index.html @@ -449,7 +449,7 @@ to_exclusive = <range>.stop
<list> = <str>.split()                       # Splits on one or more whitespace characters.
 <list> = <str>.split(sep=None, maxsplit=-1)  # Splits on 'sep' str at most 'maxsplit' times.
-<list> = <str>.splitlines(keepends=False)    # Splits on [\n\r\f\v\x1c\x1d\x1e\x85…] and \r\n.
+<list> = <str>.splitlines(keepends=False)    # On [\n\r\f\v\x1c-\x1e\x85\u2028\u2029] and \r\n.
 <str>  = <str>.join(<coll_of_strings>)       # Joins elements using string as a separator.
 
<bool> = <sub_str> in <str>                  # Checks if string contains a substring.
@@ -465,7 +465,7 @@ to_exclusive   = <range>.stop
 <int>  = ord(<str>)                          # Converts Unicode char to int.
 
    -
  • Also: 'lstrip()', 'rstrip()'.
  • +
  • Also: 'lstrip()', 'rstrip()' and 'rsplit()'.
  • Also: 'lower()', 'upper()', 'capitalize()' and 'title()'.

Property Methods

┏━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┓
@@ -480,7 +480,7 @@ to_exclusive   = <range>.stop
 
    -
  • Also: 'isspace()' checks for '[ \t\n\r\f\v…]'.
  • +
  • Also: 'isspace()' checks for '[ \t\n\r\f\v\x1c-\x1f\x85…]'.

#Regex

import re
 <str>   = re.sub(<regex>, new, text, count=0)  # Substitutes all occurrences with 'new'.
@@ -508,7 +508,7 @@ to_exclusive   = <range>.stop
 
 

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]'.
  • +
  • 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.
'\d' == '[0-9]'                                # Matches decimal characters.
 '\w' == '[a-zA-Z0-9_]'                         # Matches alphanumerics and underscore.