Do this to remove all the whitespaces. Then, subtract the length of the second string from the length of the first to determine the total number of whitespaces removed.
If you want to remove only the preceding whitespace, use "^\\s+". To remove trailing, use "\\s+$".