In Russian there is an idiom letter and spirit of the law (буква и дух закона). Letter is a metaphor for technical aspects of the law. Spirit is the purpose the law was adopted for.
There are cases, when a technically legal (in accordance with the letter part) lawsuit contradicts the purpose of the laws (the spirit part). For example, when a person sues a company for spilling coffee on themselves it's a technically correct case that misuses the laws. The purpose of the consumer protection laws is to protect people from misconduct of the companies, not from their own stupidity.
Another example: In "Breaking Bad" the agency that fights drug dealers tracks a criminal (Bob Ehrmantraut). His lawyer can't find any other way to stop this but to demand a restraining order (he accuses them of sexually harrassing the old man) on the officers in question. Again, this may be technically legal, but it goes against the intended purpose of the law.
What do you call these aspects in English? I'm looking for a nice expression or metaphor.
Sample use in a sentence:
At this point in time the Yeltsin regime already broke the law both in A and B.
A and B represent the technical and the semantic aspect of the law.