Assuming your function has the substring });
starting at character 0 at the start of the function closing line (i.e. is flush to the left), you can use
(J_Scripts?)([^.])([w|,|s|-|_|$]*)(.+?{)([^.][s|S]*?(?=(^});)))
With the multiline flag
The only modifications from your original are:
(J_Scripts?)([^.])([w|,|s|-|_|$]*)(.+?{)([^.][s|S]*?(?=^});))
// ^ ^
// | |
// non-greedy beginning of line
If your functions have a fixed offset indentation, you can exploit that just the same, using /^ {x}/
where x
is a digit representing whatever indentation count you have.
This also handles nested });
or whatever else might be in the function, so long as it's indented correctly.
If you want to capture the closing });
, add a capture group to the above pattern:
(J_Scripts?)([^.])([w|,|s|-|_|$]*)(.+?{)([^.][s|S]*?(?=(^});)))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…