I recently met code where the following regular expression was used to align spaces (and \u200c ):
\u200c
Is there a good reason to use regex or can I replace it with trim() ?
trim()
\u200c is a zero-width character without participation , which trim() does not consider spaces ( at least in Java ). You should probably use trim() if you are not expecting zero character widths without access at the beginning or end of your input, and you want to delete them - obviously, StackOverflow has this requirement.