-
Notifications
You must be signed in to change notification settings - Fork 7
/
RegEx_code.py
59 lines (41 loc) · 1.38 KB
/
RegEx_code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#RegEx Expression Patterns and Associated Code
# Match everything from start to end of the string
import re
def use_regex(input_text):
pattern = re.compile(r"^.*$")
return pattern.match(input_text)
# Combination (Alphanumeric Charaters + Characters)
import re
def use_regex(input_text):
pattern = re.compile(r"^([A-Za-z0-9]+( [A-Za-z0-9]+)+)$", re.IGNORECASE)
return pattern.match(input_text)
# Combination (Decimal number + Character)
import re
def use_regex(input_text):
pattern = re.compile(r"^([0-9]*\.[0-9]+(\|[0-9]*\.[0-9]+)+)$", re.IGNORECASE)
return pattern.match(input_text)
# Combination (Number + Character)
import re
def use_regex(input_text):
pattern = re.compile(r"^([0-9]+(\|[0-9]+)+)$", re.IGNORECASE)
return pattern.match(input_text)
# Number
import re
def use_regex(input_text):
pattern = re.compile(r"[0-9]+", re.IGNORECASE)
return pattern.match(input_text)
# Alphanumeric
import re
def use_regex(input_text):
pattern = re.compile(r"^[A-Za-z0-9]+$", re.IGNORECASE)
return pattern.match(input_text)
# Multiple Characters
import re
def use_regex(input_text):
pattern = re.compile(r"^[A-Za-z]+$", re.IGNORECASE)
return pattern.match(input_text)
# Decimal Number
import re
def use_regex(input_text):
pattern = re.compile(r"^[0-9]*\.[0-9]+$", re.IGNORECASE)
return pattern.match(input_text)