Activity › Forums › Salesforce® Discussions › How can we ignore spaces when comparing two values? Tagged: Apex Input Field, Field Value, Salesforce Apex Code, Salesforce Customization Salesforce® Discussions How can we ignore spaces when comparing two values? Posted by PRANAV on August 9, 2016 at 1:40 PM Hi All, How can we ignore spaces when comparing two values? Thanks Ajit replied 9 years, 9 months ago 2 Members · 1 Reply Apex Input FieldField ValueSalesforce Apex CodeSalesforce Customization 1 Reply Ajit Member August 10, 2016 at 11:55 AM Hi Pranav, If you are comparing string then you can use the string methods to delete white spaces from the string String s1 = ‘ Hello Jane ‘; String s2 = ‘HelloJane’; System.assertEquals(s2, s1.deleteWhitespace()); it will delete all the white spaces. tring s1 = ‘ Hello! ‘; String trimmed = s1.trim(); system.assertEquals(‘Hello!’, trimmed); it will remove trailing and leadin white spaces. Log In to reply. Public All Members My Connections Only Me PublicAll MembersMy ConnectionsOnly Me Public All Members My Connections Only Me