-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5219a3e
commit 821941f
Showing
1 changed file
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,47 @@ | ||
import re | ||
|
||
# Method | ||
|
||
def isValidExpression(regexInput,string): | ||
match = re.fullmatch(regexInput, string, re.MULTILINE) | ||
if(match != None): | ||
#print("Match found: {match}".format(start = match.start(), end = match.end(), match = match.group())) | ||
return True | ||
else: | ||
return False | ||
return False | ||
|
||
|
||
# Tests | ||
regex = r"^(?![a-z])[A-Z]([(a-z)|( )|(,)]*)([.]|[!]|[?])$" | ||
|
||
def valitateStringList(listOfStrings): | ||
for expression in listOfStrings: | ||
if(isValidExpression(regex,expression)): | ||
print("---Test passed for expression: '" + expression + "'") | ||
else: | ||
print("!!!Test failed. Invalid expression '" + expression + "' is not compatible with regex input.") | ||
|
||
valid_strings_list = [ | ||
"Be kind, for everyone you meet is fighting a harder battle.", | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", | ||
"Aaaaaaaaaaaaa.", | ||
"Aaaaaaaaaaaaa!", | ||
"Aaaaaaaaaaaaa?", | ||
"Aaaaaaa aaaaa aaaaaaa.", | ||
"Asafsafsafassaffsaafssfaasf.", | ||
"Aaaaaa,aaaaaaa.", | ||
] | ||
|
||
invalid_strings_list = [ | ||
"Invalid because cammelCase.", | ||
"INVALID BECAUSE UPPERCASE.", | ||
"Invalid because mbers like 1 to 9.", | ||
"Invalid because multiple dots...", | ||
"Invalid because multiple exclamations!!!", | ||
"Invalid because numbers like 1 to 9..", | ||
"Invalid because #@#&*+- characters.", | ||
"Invalid because áóéíãõââ characters.", | ||
"Invalid because áóéíãõââ characters.", | ||
] | ||
|
||
valitateStringList(valid_strings_list) | ||
valitateStringList(invalid_strings_list) |