The answer to that situation would be to Dresden the entire Gaza strip, but Israel would never do it.
Modifying that a little. If a house, mosque, etc. has weapons, booby traps, etc. then remove everyone and bulldoze. Rinse and repeat.
Most civilians don’t understand that a conflict only ends when the loser decides it is. The sad truth is that these pinprick operations that minimize civilian suffering will never win a war.