One of these might work with javascript.
overrun protected with <name>
str = '
<div
(?=\s)
(?= (?:[^>"\']|"[^"]*"|\'[^\']*\')*? (?<=\s) id \s*=
(?: (?> \s* ([\'"]) \s* a_secret \s* \g{-1} )
| (?> (?!\s*[\'"]) \s* a_secret (?=\s|>) )
)
)
(?> \s+ (?:".*?"|\'.*?\'|[^>]*?)+
>
) (?<! /> )
(?<not_71drwec3>(?:(?!71drwec3).)*?) </div\s*>
';
unprotected with <name>
str = '
<div
(?=\s)
(?= (?:[^>"\']|"[^"]*"|\'[^\']*\')*? (?<=\s) id \s*=
(?: \s* ([\'"]) \s* a_secret \s* \g{-1}
| (?!\s*[\'"]) \s* a_secret (?=\s|>)
)
)
\s+ (?:".*?"|\'.*?\'|[^>]*?)+
>
(?<! /> ) // line is worthless when unprotected
(?<not_71drwec3>(?:(?!71drwec3).)*?) </div\s*>
';
unprotected no <name> without \g{} notation
str = '
<div
(?=\s)
(?= (?:[^>"\']|"[^"]*"|\'[^\']*\')*? (?<=\s) id \s*=
(?: \s* ([\'"]) \s* a_secret \s* \1 // Group 1
| (?!\s*[\'"]) \s* a_secret (?=\s|>)
)
)
\s+ (?:".*?"|\'.*?\'|[^>]*?)+
>
(?<! /> ) // line is worthless when unprotected
((?:(?!71drwec3).)*?) </div\s*> // Group 2
';