获得固定字符串匹配

I have the following fixed string.

edbe801bf92fe7b770f72df2d722df0a

I need to get the 2df2d part after the fourth 7 and before the last 7

I tried matching with

[a-z0-9]*7[a-z0-9]*77[a-z0-9]*7(.*)

But its getting the wrong part of the string

Thanks.

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