Hi Nicole Baptista,
If you convert the $Variable string to UTF-16 or ASCII character, you will find out the difference between non-breaking spaces and normal spaces. Non-breaking spaces are not considered Space. So If we use trim() or replaceAll() function,
It will not work. You need to manually replace these non-breaking spaces with normal spaces and then apply replaceAll($Variable,' ','') to remove all the spaces in that string. For your reference, I will share the ASCII converter and UTF-16 converter links to verify, whether $Variable has non-breaking spaces or not. horizontal space (\u00a0) is one of the non-breaking space. Just check this one.
White space character table doc link : https://en.wikipedia.org/wiki/Whitespace_character
If it's there, just replaces this \u00a0 with normal space.
I hope it will solve your issue!
Thanks and regards,