Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whatiskeptiname #391

Merged
merged 6 commits into from
Oct 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import re # import regex module

# check if date is valid (yyyy-mm-dd)
def date_validation(self, date):
if re.fullmatch(r"/^\d{4}-\d{2}-\d{2}$/", date):
return True
else:
return False


date_validation("2022-02-29") # False/True
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import re # import reges module

string = "sixteen:16 Eighty three:83."
pattern = "\d+"

def split_string(pattern, string)
result = re.split(pattern, string)
return result

print(split_string(pattern, string))

# Output: ['sixteen:', ' Eighty three:', '.']
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# simple string matching and other normal validation using regular expressions
# check if the string matches with the given pattern

import re # import regular expression module

# class for regex snippets
class regex:
def __init__(self) -> None:
pass
# Matching string
def str_match(pattern, string):
if re.search(pattern, string):
return True
else:
return False

# Matching string
def str_match(self, pattern, string):
if re.search(pattern, string):
return True
else:
return False

str_match("[a-z]", "a") # True/False
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import re # import regex module


# check if the username is valid
def username_validation(self, username):
if re.fullmatch(r"^(?=[a-zA-Z0-9._]{8,20}$)(?!.*[_.]{2})[^_.].*[^_.]$", username):
return True
else:
return False


username_validation("youlot44") # True/False
16 changes: 16 additions & 0 deletions Program's_Contributed_By_Contributors/Python_Programs/timer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Countdown timer
import time # import time


def countdown(time_sec):
while time_sec:
mins, secs = divmod(time_sec, 60)
timeformat = "{:02d}:{:02d}".format(mins, secs)
print(timeformat, end="\r")
time.sleep(1)
time_sec -= 1

print("stop")


countdown(5)