Actually your pattern will match if you add another 7
after your capturing group.
.... (.*)7
But for readability and to save you a headache, I would simplify this.
(?:[^7]*7){4}([^7]*)
I used a non-capturing group here ?:
to group the expression for multiple matches, but not to save it as a matched/captured portion of the string.
Regular expression explanation:
(?: group, but do not capture (4 times):
[^7]* any character except: '7' (0 or more times)
7 match '7'
){4} end of grouping
( group and capture to \1:
[^7]* any character except: '7' (0 or more times)
) end of \1
See live demo