-1

We have a list of words that sometimes the users or the system injects "space" in between letter, e.g. "happy" would sometimes input as "h appy" or "h a p py" or "ha p p y".

What is the best method to remove the spaces in the list of words, such as "happy" above? The words are in a sentence, e.g. "I feel hap py today." I only need to correct those key words in a list and not the whole sentence.

This is NOT the same question as removing white-space from a single word.

Duc Haba
  • 41
  • 4

1 Answers1

0

Assuming that you're using a html form to get the data and can use javascript to manipulate it.

Use this code to remove spaces from the entered text:

var str = "h a p p y";
str = str.replace(/ +/g, "");
Nabeel Khan
  • 3,715
  • 2
  • 24
  • 37