Such a range of meaning for so small a word.
An exclamation expressing, according to the intonation, various emotions, as
1. Sorrow, lamentation, regret, passing into the regretful expression of a vain wish. (Actual pain or suffering is now more commonly expressed by O! Oh! North. dial. have a (eː) in both senses.)
2. Surprise, wonder, admiration.
In the two prec. senses often followed by me (north. eh me!). Cf. It. ahime!
3. Entreaty, appeal, remonstrance; passing in former times into simple exclamation to excite attention, where O! would now be used. (North. dial. still have ā man!)
4. Dislike, aversion; passing into contempt, mockery, exultation over or satisfaction at misfortune.
5. Opposition, objection (to what has been said). Often followed by but.
Mod. Ah! but I know something better than that.
6. Realization, discovery, inspiration.