38 “You have heard that it was said, An eye for an eye and a tooth for a tooth. 39 But I tell you, don’t resist an evildoer. On the contrary, if anyone slaps you on your right cheek, turn the other to him also. 40 As for the one who wants to sue you and take away your shirt, let him have your coat as well. 41 And if anyone forces you to go one mile, go with him two. 42 Give to the one who asks you, and don’t turn away from the one who wants to borrow from you.
43 “You have heard that it was said, Love your neighbor and hate your enemy. 44 But I tell you, love your enemies and pray for those who persecute you, 45 so that you may be sons of your Father in heaven. For He causes His sun to rise on the evil and the good, and sends rain on the righteous and the unrighteous. 46 For if you love those who love you, what reward will you have? Don’t even the tax collectors do the same? 47 And if you greet only your brothers, what are you doing out of the ordinary? Don’t even the Gentiles do the same? 48 Be perfect, therefore, as your heavenly Father is perfect. (Matthew 5:38-48 HCSB)
22 “When men get in a fight and hit a pregnant woman so that her children are born prematurely but there is no injury, the one who hit her must be fined as the woman’s husband demands from him, and he must pay according to judicial assessment. 23 If there is an injury, then you must give life for life, 24 eye for eye, tooth for tooth, hand for hand, foot for foot, 25 burn for burn, bruise for bruise, wound for wound. (Exodus 21:22-25)
I believe that the two passages above do not contradict. People often mistake the verses.
The Pharisees took the passage from exodus to mean, "If you hit me then I am entitled to hitting you back," but according to Jesus' words, that's not what the text means. Jesus was upholding the Law. He corrected His disciples from the poison of the Pharisees to the true meaning of the text.
Jesus wasn't teaching against civil justice for assault, He was merely teaching an old truth of the Law, to love your enemy. As the Law of Exodus also said:
If you come across your enemy’s stray ox or donkey, you must return it to him. If you see the donkey of someone who hates you lying helpless under its load, and you want to refrain from helping it, you must help with it. (Exodus 23:4-5 HCSB)
Thus Jesus upheld this by teaching us to love our enemies. So what was Jesus forbidding in the fifth chapter of Matthew? He was forbidding personal retaliation done in wrath, in lieu of civil justice. It is perfectly fine to demand justice when someone does something wrong, but it is sinful to take matters into your own hands, hold grudges, and seek revenge (Matt 18:21-35; Romans 12:19).
As Jesus said, the Pharisees often neglected one of the most important aspects of the Law: Justice (Matt 23:23-24).
Hope this helps you get a look at the Christian's view on the verses.