forked from nathan-abela/HackerRank-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02 - Excluding Specific Characters.py
More file actions
40 lines (33 loc) · 1.16 KB
/
02 - Excluding Specific Characters.py
File metadata and controls
40 lines (33 loc) · 1.16 KB
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
# ========================
# Information
# ========================
# Direct Link: https://www.hackerrank.com/challenges/excluding-specific-characters/problem
# Difficulty: Easy
# Max Score: 10
# Language: Python
# ========================
# Solution
# ========================
import re
regex_pattern = r'^\D[^aeiou][^bcDF]\S[^AEIOU][^.,]$'
# Regex Pattern:
# .
# ├── ^
# │ └── Denotes the start of the line
# ├── \D
# │ └── Denotes any character that is not a digit (equal to [^0-9])
# ├── [^aeiou]
# │ └── Denotes any single character not included in the list 'aeiou'
# ├── [^bcDF]
# │ └── Denotes any single character not included in the list 'bcDF'
# ├── \S
# │ └── Denotes any non-whitespace character (equal to [^\r\n\t\f\v ])
# ├── [^AEIOU]
# │ └── Denotes any single character not included in the list 'AEIOU'
# ├── [^.,]
# │ └── Denotes any single character not included in the list '.,'
# └── $
# └── Denotes the end of the line
# Example: think?
# Example: fluff!
print(str(bool(re.search(regex_pattern, input()))).lower())