Repository navigation
Expand file tree
/
Copy pathtrial-error.py
More file actions
293 lines (232 loc) · 7.46 KB
/
Copy pathtrial-error.py
File metadata and controls
293 lines (232 loc) · 7.46 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# Import
# import re
# class Employee :
# def __init__(self, first, last, badge, dept, title) :
# # Maybe use? changes format from "first, last" to "first last"
# # x = name.split()
# # self.name1 = x[0]
# # self.name2 = x[1]
# # Attributes to store
# self.first = first
# self.last = last
# self.id = badge
# self.dept = dept
# self.title = title
# # \d for searching for digits
# pattern = re.compile(r'\d\d\d\d\d')
# badgeTest = "12345"
# match = pattern.finditer(badgeTest)
# for match in match :
# print(match)
### USE FOR SCRIPT?
# print(len(badge))
# pattern = re.compile(r'\d\d\d\d\d')
# checkBadge = pattern.finditer(badge)
# try:
# if len(badge) != 5 :
# raise ValueError
# elif len(badge) == 5 :
# self.badge = badge
# except ValueError :
# test = input("Enter employee ID number in format 12345")
# testLargeString = ''' This
# Is a test
# for multi line string inputs
# ! @ # $ % ^ & * ( ) + = - ~ `
# < > ? , . /
# LURKING IN
# THE SHADOW IS A
# FUCK TWAT COMING 4 U
# 123-456-789000
# '''
# print(testLargeString)
# # TESTING BULLSHIT
# # name = "John Doe"
# first = "Richie"
# last = "Door"
# badge = "12345"
# dept = "Accounting"
# title = "Manager"
# test = Employee(first, last, badge, dept, title)
# # print(test.name1)
# # print(test.name2)
# print(test.first)
# print(test.last)
# print(test.id)
# print(test.dept)
# print(test.title)
# # # Testing for regex script portion
# phoneNumRegex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d')
# mo = phoneNumRegex.search("""fuck
# 777-777-7777
# (777)-817-3213""")
# print('Phone number found: ' + mo.group())
# print(mo)
# # # FUCK YES THIS RIGHT HERE IS THE RIGHT SHIT :D WOO
# empID = input("Enter employee ID: ")
# if re.search(r"^\d{5}$", empID) :
# print("Correct syntax")
# else :
# print("Incorrect syntax")
# # # COPY/PASTE ME***************************
# name = input("\nEnter the name of the employee: ")
# namePattern = re.search(r"^\w+ \w+$", name)
# try :
# if name and namePattern :
# if name.split() == IndexError :
# raise IndexError
# else :
# fullName = name.split()
# first, last = fullName[0], fullName[1]
# elif namePattern == None :
# raise IndexError
# except IndexError :
# clear()
# print("\nMust enter first and last name only")
# empID = input("Enter the employee ID: ")
# idPattern = re.search(r"^\d{5}$", empID)
# if empID :
# if idPattern :
# empID = int(empID)
# else :
# print("\nInvalid ID entry. Enter ID format 12345")
# else :
# print("\nField cannot be empty")
# ## YAY! Correct code for a regex match on name and splitting
# # Testing section for name regex?
# name = input("\nEnter the name of the employee: ")
# #regex = re.compile(name)
# namesearch = re.search(r"^\w+ \w+$", name)
# print(namesearch)
# if namesearch:
# print("correct input")
# elif namesearch == None :
# print("Invalid name")
# try:
# if name :
# if name.split() == IndexError :
# raise IndexError
# else :
# fullName = name.split()
# first, last = fullName[0], fullName[1]
# else :
# print("\nField cannot be empty\n")
# except IndexError :
# print("\nMust enter first and last name only")
# #TESTING FOR PROJECT NINE
# day = input("Enter the day of a month: ")
# month = input("Enter a month's number: ")
# year = input("Enter a year: ")
# # day = int(day)
# # month = int(month)
# # year = int(year)
# print(day,month,year)
# print(type(day))
# print(type(month))
# print(type(year))
# # w = day + 2*month + int(0.6)*month+1 + year + year/4 - year/100 + year/400 +2
# w = int(day) + 2 * int(month) + int(0.6) * int(month) + 1 + int(year) + int(year)/4 - int(year)/100 + int(year)/400 +2
# print(w%7)
# ## TRIAL SHIT FOR READ WRITE
# from sys import exit
# class Person(object):
# def __init__(self):
# self.name = ""
# self.address = ""
# self.phone = ""
# self.age = ""
# self.whip = {}
# def writing(self):
# self.whip[p.name] = p.age, p.address, p.phone
# target = open('deed.txt', 'a')
# target.write(str(self.whip))
# print (self.whip)
# def reading(self):
# self.whip = open('deed.txt', 'r').read()
# name = input("> ")
# if name in self.whip:
# print (self.whip[name])
# p = Person()
# while True:
# print ("Type:\n\t*read to read data base\n\t*write to write to data base\n\t*exit to exit")
# action = input("\n> ")
# if "write" in action:
# p.name = input("Name?\n> ")
# p.phone = input("Phone Number?\n> ")
# p.age = input("Age?\n> ")
# p.address = input("Address?\n>")
# p.writing()
# elif "read" in action:
# p.reading()
# elif "exit" in action:
# exit(0)
# ## SAVE OF TRY / EXCEPT BEGINNING OF SCRIPT // copy this back if it doesnt work
# try :
# database = "employee_database.txt"
# dictionary = {}
# if does_file_exist(database) == True :
# inputFile = open(database, 'r')
# for line in inputFile :
# idregex = re.compile(r"^\d{5}")
# mo = idregex.search(line)
# print(mo.group())
# empid = re.search(r"^\d{5}", line)
# print(empid.group())
# name = re.search(r"^\w+ \w+", line)
# print(name.group())
# print(line)
# first = line[1]
# last = line[2]
# empid = line[0]
# dept = line[3]
# title = line[4]
# addMe = {}
# obj = Employee(first, last, empid, dept, title)
# addMe[empid] = obj
# dictionary.update(addMe)
# inputFile.close()
# elif does_file_exist(database) == False :
# raise FileNotFoundError
# except FileNotFoundError :
# print("\nDatabase does not exist, creating now....")
# outputFile = open(database, "w")
# outputFile.close()
# time.sleep(.75)
# # MENU SIX COPY
# def menuSix() :
# #Logic to store data to file *** INPUT HUR
# print("\nSaving dictionary to databse...")
# print("********************\n")
# f = open(database, "w")
# for key in dictionary :
# f.write(str(dictionary[key].id))
# f.write(" ")
# f.write(str(dictionary[key].name))
# f.write(" ")
# f.write(str(dictionary[key].department))
# f.write(" ")
# f.write(str(dictionary[key].title))
# # f.write(str(dictionary))
# f.write("\n")
# f.close()
# time.sleep(.25)
# # Exit
# print("\nExiting program...")
# print("********************\n")
# time.sleep(.75)
# clear()
# sys.exit()
import re
# FINAL BULLSHIT
textsearch = ''' Hello
hello
maybe
finite
ABC123 '''
hello = "Hello"
hello2 = "hello"
maybe = "maybe"
finite = "finite"
abc = "ty"
pattern = re.search(r"[a-g]", abc)
print(pattern)