This quote is attributed to Shaw only.
Quote:
LORD DARLINGTON. This woman has purity and innocence. She has everything we men have lost.
CECIL GRAHAM. My dear fellow, what on earth should we men do going about with purity and innocence? A carefully thought-out buttonhole is much more effective.
DUMBY. She doesn't really love you then?
LORD DARLINGTON. No, she does not!
DUMBY. I congratulate you, my dear fellow. In this world there are only two tragedies. One is not getting what one wants, and the other is getting it. The last is much the worst; the last is a real tragedy! But I am interested to hear she does not love you. How long could you love a woman who didn't love you, Cecil?
CECIL GRAHAM. A woman who didn't love me? Oh, all my life!
DUMBY. So could I. But it's so difficult to meet one.
~from Lady Windermere's Fan, by Oscar Wilde
I find the version attributed to Shaw going this way:
There are two great tragedies in life. One is to lose your heart's desire, the other is to gain it.
~George Bernard Shaw