Martin posted the following question on the page Make Territory While Attacking:
How do I make territory by attacking?
Martin: I think I was looking for more general principles, rather than specific examples, though the specific examples are helpful too. If my opponent has a relatively weak group, or even a single stone, between two of my relatively stronger groups, it seems like attacking it makes things worse more often than better. Typically they run away to the center, and in the process they get strong enough to kill one of my groups, or they join up with another group that was weak and make it stronger.
Bob McGuigan: I think it's hard to give general priciples because everything depends on the position. But from your description it sounds like you may be trying too hard to kill. Even if your opponent has a weak group, it may not be possible to kill it and trying too hard can make your attacking stones vulnerable. Simply put, you make territory while attacking by threatening the weak group with moves that also build territory or expand or strengthen a framework. The idea is that your opponent has to defend the weak group so you get the profit without interference. Sometimes you can get profit by making a leaning attack. If you are aiming at a group you threaten or put pressure on a different group in such a way that when/if your opponent defends you attacking stones give you useful strength for the attack you really want to make. Anyhow, the key idea is that you don't expect to kill by attacking but rather you want to build territory by making your opponent defend. An example might be where you have a choice of (1) blocking access to the center or (2) taking away the eye space of your opponent's group forcing it to run into the center. Option (1) might let/make your opponent live in a small area on the side while you get points on the outside. Option (2) might cause the scenario you describe when your opponent runs into the center.
Bill: Your example sounds like something besides making territory while attacking. Rather than making an attack that pushes weak stones out into the center, it is often better to contain the weak stones, even if they can make small life.
In general there is no mystery to making territory while attacking. It is the same as attacking while making territory. You simply make plays that do both. The different functions are usually clear. (Of course, there are sophisticated examples, as well.)
Martin: Thank you. I've been trying to apply this straight-forward advice in my games, and it's been helpful. I think my problem was in continuing attacks too long. I start off making territory by attacking, but end up just attacking. So it is a question of learning when to stop, rather than when to start.