Browse Source

Format

pull/3/head
Jure Šorn 6 years ago
parent
commit
06d4282908
1 changed files with 8 additions and 4 deletions
  1. 12
      README.md

12
README.md

@ -236,7 +236,9 @@ String
print(<el_1> [, <el_2>, end='', sep='', file=<file>]) # Use 'file=sys.stderr' for errors. print(<el_1> [, <el_2>, end='', sep='', file=<file>]) # Use 'file=sys.stderr' for errors.
``` ```
### Regex Regex
-----
```python ```python
import re import re
<str> = re.sub(<regex>, new, text, count=0) # Substitutes all occurrences. <str> = re.sub(<regex>, new, text, count=0) # Substitutes all occurrences.
@ -251,7 +253,7 @@ import re
* **Use '\\\\1' or r'\1' for backreference.** * **Use '\\\\1' or r'\1' for backreference.**
* **Use ? to make operators non-greedy.** * **Use ? to make operators non-greedy.**
#### Match object: ### Match Object
```python ```python
<str> = <Match>.group() # Whole match. <str> = <Match>.group() # Whole match.
<str> = <Match>.group(1) # Part in first bracket. <str> = <Match>.group(1) # Part in first bracket.
@ -259,7 +261,7 @@ import re
<int> = <Match>.end() # Exclusive end index of a match. <int> = <Match>.end() # Exclusive end index of a match.
``` ```
#### Special sequences: ### Special Sequences
```python ```python
# Use capital letter for negation. # Use capital letter for negation.
'\d' == '[0-9]' # Digit '\d' == '[0-9]' # Digit
@ -267,7 +269,9 @@ import re
'\w' == '[a-zA-Z0-9_]' # Alphanumeric '\w' == '[a-zA-Z0-9_]' # Alphanumeric
``` ```
### Format Format
------
```python ```python
# Both return '<el_1>, <el_2>': # Both return '<el_1>, <el_2>':
<str> = '{}, {}'.format(<el_1>, <el_2>) <str> = '{}, {}'.format(<el_1>, <el_2>)

|||||||
100:0
Loading…
Cancel
Save