Q:

How to use regular expression extract data not followed by something with pandas

I just want to extract the years, but not the number. How can I define not followed by XXX?
I made the following example, but the result is always a literal more than I expected. 
text = ["hi2017", "322017"]
text = pd.Series(text)
myPat = "([^\d]\d{4})"

res = text.str.extract(myPat)
res

Then I get the result:
0    i2017
1      NaN
dtype: object

Actually, I just want to get "2017", but not "i2017", how can I do it?
PS. The "322017" should not be extracted, because it is not a year, but a number

A:

Give this a try:
(?<!\d)(\d{4})(?!\d)

which returns 2017 and is based almost entirely on the comment by @PauloAlmeida

