+ Start a Discussion
Ravindar AdminRavindar Admin 

How to remove the spaces in before and after the string(Not middle space) dynamically?

I am trying to remove space(dynamically) of input string:

Example: string: ' inputString ', Expecting O/p: 'inputString'
Example like : ' Ravi kumar ' Expecting O/p:'Ravi kumar'

I want to remove the space before or after the string or both before and after, not in the middle.

I tried the following but it is removing all the spaces including middle.

inputString = inputString .replaceAll( '\s+', '');
Best Answer chosen by Ravindar Admin
JLA.ovhJLA.ovh
... or better : use trim()

All Answers

JLA.ovhJLA.ovh
you could try to use the String method normalizeSpace()
JLA.ovhJLA.ovh
... or better : use trim()
This was selected as the best answer