On hearing about two factions infatuated with a courtesan, the Buddha expresses an inspired utterance on the extremes - one of taking rules and observances as the essence and the other of seeing no fault in sensual pleasures.

Gaṇikā sutta - Courtesan

Thus have I heard - At one time, the Blessed One was dwelling in Rājagaha, in the Bamboo Grove, the Squirrels' feeding ground. At that time, two factions in Rājagaha were infatuated with a certain courtesan, obsessed in their minds. Accusing, quarrelling, and having fallen into dispute, they assaulted one another with fists, stones, sticks, and knives, encountering death or death-like suffering.

Then, several bhikkhus, having dressed in the morning and taking their bowls and robes, entered Rājagaha for alms. Having walked for alms in Rājagaha, and after their meal, they went to the Blessed One. Having approached the Blessed One, they paid homage to him and sat down to one side. Seated to one side, those bhikkhus said to the Blessed One:

"Venerable sir, here in Rājagaha, two factions are infatuated with a certain courtesan, obsessed in their minds. Accusing, quarrelling, and having fallen into dispute, they assault one another with fists, stones, sticks, and knives, encountering death or death-like suffering."

Then, understanding the significance of this, the Blessed One at that time expressed this inspired utterance:

"What has been accomplished and what is to be accomplished—both are strewn with dust for one who practices in line with the afflicted. Those who regard training rules as the essencerules and observances, celibacy, and service as the essence—this is one extreme. And those who say, 'There is no fault in sensual pleasures,' this is the other extreme. Both these extremes heap up the cemetery; and cemeteries cause views to grow. Without directly knowing both these extremes, some get stuck, while others overshoot the mark. But those who, directly knowing these [two extremes], do not become by them, and do not define themselves by that—for them, no cycle of existence can be designated."