Your objects should have a field indicating order number.
If that is not possible and all you've got is a text field then you'll have to apply trimming to user input when it's transferred to back-end.
Also trim should be applied to text values in your storage. Then you invent some matching mechanism. This mechanism will depend on the technology that you use to access your data, if it is a database then some LIKE SQL statement.