To use regex to extract any numbers of length greater than 2, in a string, but also exclude "2016", here is what I have:
import re
string = "Employee ID DF856, Year 2016, Department Finance, Team 2, Location 112 "
print re.findall(r'\d{3,}', string)
output:
['856', '2016', '112']
I tried to change it to below to exclude "2016" but all failed.
print re.findall(r'\d{3,}/^(!2016)/', string)
print re.findall(r"\d{3,}/?!2016/", string)
print re.findall(r"\d{3,}!'2016'", string)
What is the right way to do it? Thank you.
the question was extended, please see the final comment made by Wiktor Stribiżew for the update.