I got HTML element contains this:
P6C245RO
You can remove all instances of congruent whitespace and newlines like so
// Note: console.log() requires Firebug
var str = ' this is \n some text \r don\'t \t you know? ';
console.log( str );
str = str.replace( /[\s\n\r]+/g, ' ' );
console.log( str );
Then to clean it up and apply it to your jQuery
$.trim( $element.text().replace( /[\s\n\r]+/g, ' ' ) )