function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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