While this seems very sketchy, I am doing this for my MGMT288 class, and am trying to create a program that searches for a SSN from a group of copied text. I have very little python background, and am just exploring regex and in extension pyperclip. Currently my code in the entirety looks like this.
import re,pyperclip
SSNREG=re.compile(r'(\d{3})(-)?(\d{2})(-)?(\d{4})')
SSN=[]
CB=pyperclip.paste()
for groups in SSNREG.findall(CB):
SSN.append(groups[0])
if len(SSN)>0:
pyperclip.copy('\n'.join(CB))
print('Copied '+len(CB)+' SSN\'s to clipboard!')
print('\n'.join(CB))
else:
print('There were no SSN\'s to be found in the text.')
Whenever I have a 3-2-4 digit number copied with the dashes, it still prints out that there were no SSN's in the clipboard, and I can't figure out what's wrong.
I've just changed the /d to \d and it still doesn't seem to find anything.