About this question
Can anyone confirm that Unicode u00A0 non-breaking space is not considered "whitespace" by Apex and is not detected by trim(), deleteWhitespace, or regex? I'm surprised by regex since I thought s was supposed to include non-breaking spaces. Of the methods below, only replaceAll with the character code works.
String x = 'u00A0' + 'Test'; String y = x.unescapeUnicode(); system.debug('### y trim length: ' + y.trim().length()); system.debug('### y deleteWhitespace length: ' + y.deleteWhitespace().length()); system.debug('### y replaceall regex length: ' + y.replaceAll('\s', '').length()); system.debug('### y replaceall unicode length: ' + y.replaceAll('\u00A0', '').length());