Skip to content

Commit dae3c53

Browse files
committed
add doc
1 parent a57a7f8 commit dae3c53

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

regex.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
# regex using module re to match patterns
2+
3+
'''
4+
MetaCharacters
5+
Metacharacters are characters that are interpreted in a special way by a RegEx engine. Here's a list of metacharacters:
6+
7+
[] . ^ $ * + ? {} () \ |
8+
9+
Here, [abc] will match if the string you are trying to match contains any of the a, b or c.
10+
11+
You can also specify a range of characters using - inside square brackets.
12+
13+
[a-e] is the same as [abcde].
14+
[1-4] is the same as [1234].
15+
[0-39] is the same as [01239].
16+
17+
You can complement (invert) the character set by using caret ^ symbol at the start of a square-bracket.
18+
19+
[^abc] means any character except a or b or c.
20+
[^0-9] means any non-digit character.
21+
'''
222
import re
323
pattern = '^a...s$'
424
test_string = 'abyss'
@@ -7,4 +27,4 @@
727
if result:
828
print('Pattern matched')
929
else:
10-
print('Pattern not matched')
30+
print('Pattern not matched')

0 commit comments

Comments
 (0)