user1769667
user1769667

Reputation: 339

Javascript tab character removal

I need to remove tab characters within text inputted into particular fields of a web interface. The problem seems to be that when this happens the resulting text now contains spaces where the tabs were.

I tried using the regex : vVal = vVal.replace(/(\s+)/, ""); but using the example input 11111[tab], the value becomes 11111[space].

I dont know how this could be..

Upvotes: 5

Views: 14276

Answers (1)

anubhava
anubhava

Reputation: 785691

\s matches any whitespace that includes space also.

For tab try \t with global switch:

vVal = vVal.replace(/\t+/g, "");

Upvotes: 10

Related Questions