Skip to content

Commit

Permalink
Merge pull request #4 from thecoding-society/rollno
Browse files Browse the repository at this point in the history
fixed regex to avoid 000-099 roll nos
  • Loading branch information
aviiciii authored Feb 1, 2023
2 parents fcea858 + 34e4627 commit 0a3cf7f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/rollno/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


# Regex for rollno
regex_rollno = r'^(20[1-3]{1}[0-9]{1})(PEC)([A-Z]{2})([0-9]{3})$'
regex_rollno = r'^(20[1-3]{1}[0-9]{1})(PEC)([A-Z]{2})([1-9]{1}[0-9]{3})$'

def isvalid(rollno):
"""
Expand All @@ -24,8 +24,10 @@ def parse(rollno, required):
"""
Parse rollno
Returns parsed rollno if valid, None otherwise
Required = year, college_code, department_code, shortrollno
"""


# Check if rollno is valid
if isvalid(rollno):

Expand All @@ -43,14 +45,17 @@ def parse(rollno, required):
# Get college code
college_code = re.group(2)
return college_code

elif required == 'department_code':
# Get department code
department_code = re.group(3)
return department_code

elif required == 'shortrollno':
# Get shortrollno
shortrollno = re.group(4)
return shortrollno

else:
return None
else:
Expand All @@ -77,7 +82,7 @@ def get_dept_code(rollno):
def get_dept(rollno):
"""
Get department from rollno
Returns department if valid, None otherwise
Returns department name if valid, None otherwise
"""

# Check if rollno is valid
Expand Down

0 comments on commit 0a3cf7f

Please sign in to comment.