Browse Source

Regex

pull/3/head
Jure Šorn 6 years ago
parent
commit
9ac70aee69
1 changed files with 3 additions and 2 deletions
  1. 5
      README.md

5
README.md

@ -162,14 +162,15 @@ print(<el> [, <el>, end='', sep='', file=<file>])
```python ```python
import re import re
re.sub(<regex>, new, text, count=0) re.sub(<regex>, new, text, count=0)
re.search(<regex>, text) # Searches for first occurance of pattern.
re.search(<regex>, text) # Searches for first occurrence of pattern.
re.match(<regex>, text) # Searches only at the beginning of the string. re.match(<regex>, text) # Searches only at the beginning of the string.
re.findall(<regex>, text) re.findall(<regex>, text)
re.split(<regex>, text, maxsplit=0) # Use brackets in regex to keep the matches. re.split(<regex>, text, maxsplit=0) # Use brackets in regex to keep the matches.
``` ```
**_Search_ and _match_ functions return a 'Match' object. Use '.group()' method on it to get the match.** **_Search_ and _match_ functions return a 'Match' object. Use '.group()' method on it to get the match.**
**Parameter 'flags=re.IGNORECASE' can be used with all functions.**
**Parameter 'flags=re.IGNORECASE' can be used with all functions.**
**Parameter 'flags=re.DOTALL' makes dot also accept newline.
**Use r'\1' for backreference.** **Use r'\1' for backreference.**
#### Special Sequences: #### Special Sequences:

Loading…
Cancel
Save