24 lines
687 B
Python
24 lines
687 B
Python
import re
|
|
|
|
expressions = {
|
|
'first_name': "(?<=first\sname:\s)(.*)",
|
|
'last_name': "(?<=last\sname:\s)(.*)",
|
|
'hire_date': "(?!Hire\sDate:\s)((1[0-2])|([1-9]))/(([1-2][0-9])|([1-9])|(3[0-1]))/[0-9]{4}",
|
|
'title': "(?<=title:\s)(.*)",
|
|
'department': "(?<=department:\s)(.*)",
|
|
'manager': "(?<=manager:\s)(.*)",
|
|
'initial_comments': "(?<=comments:\s)(.*)",
|
|
'it_requests': "(?<=it\srequests:\s)(.*)",
|
|
}
|
|
|
|
|
|
def process_regex(initial_data):
|
|
data = {}
|
|
|
|
for key, value in expressions.items():
|
|
try:
|
|
data[key] = re.search(value, initial_data, re.IGNORECASE).group()
|
|
except AttributeError:
|
|
data[key] = 'None'
|
|
|
|
return data |