The last modifications of this post were around 4 years ago, some information may be outdated!
This is a draft, the content is not complete and of poor quality!
On this page
We can select string with some patterns.
Import library
import reSpecial characters
.matches any character except a newline^aall strings starting with'a'a$all strings ending with'a'ab+matches'ab','abb'but not'a','ac'.[bcr]atany characters within[]can be filled the space- Using
\to escape special characters\s: whitespace characters.\S: any except whitespace.\b: empty strings (only at the beginning or end of a word).\B:
cat|dogwould match'catfish'and'hotdog'for begin and end characters[amk]will match'a','m', or `'k``[0-9]will match any character that falls between0and9[a-z]: lowercase[0-9]{4}: repeat the pattern[0-9]four times by writinga{m,n}matches frommtonrepetitions of'a'.a{m,}matches frommto infinity repetitions of'a'.
References
- Python docs -- Regular Expression.
💬 Comments