If God is omniscient how can he regret? It is said in the bible that God is omniscient but if he is omniscient how can he regret his actions?

I'm especially interested in this question in context of Genesis 6:6:


  The LORD was sorry that He had made man on the earth, and He was grieved in His heart.
This is an anthropomorphism, which according to The New Jerome Biblical Commentary, 77:20, page 1288:


  21. (the first of three paragraphs on the subject) The attribution of human features and behavior to nonhuman beings (along with anthropopathism - the attribution of human feelings) is common in both religious and profane literature of all cultures. What makes anthropomorphism worthy of special attention in the OT is the difficulty of reconciling it with the prohibition of images and the explicit denials that Yahweh is like any created being. The fear of a plastic image of Yahweh is in marked contrast to the lack of restraint in employing verbal images. Yahweh has a countenance, eyes, ears, mouth nostrils, hands, feet. He speaks, hears, smells, laughs, hisses, whistles, strikes, writes, walks. He feels delight, joy, anger, hatred, love, disgust, compassion (see e.g., T. E. Fretheim, The Suffering of God [OBT 14; Ph, 1984]. The OT never speaks of Yahweh without attributing human traits to him. There is scarcely any OT anthropomorphism that cannot be paralleled in other ancient Semitic literature; for the gods of other ancient Semitic peoples were personifications of natural forces or social realities to whom were attributed human features and behavior.


So it should be clear God does not literally regret, but this is an anthropomorphism to express an inexpressible idea.