A new characterization of Sobolev spaces