I am having trouble figuring out the correct way to write my code to find all the cells that fit my regular expression. This is what I have so far. I know i cant just equate the cell value to my regular expression but i do not know how to go about doing so.
import openpyxl
import re
date = re.compile(r'\d{1,2}[\/-]\d{1,2}[\/-]18-\d{1,2}[\/-]\d{1,2}[\/-](18|19)')
for sheet in wb:
for row in sheet.iter_rows():
for cell in row:
if cell.value == date:
print (cell.value)
Examples:
IN: mo = date.search('Support Term 3/7/18-3/6/18')
IN: mo.group()
OUT: '3/7/18-3/6/18'
(i tested my regex and it works how i want it to but my for loop needs some work obviously)