• +91 9723535972
  • info@interviewmaterial.com

Regular Expressions Interview Questions and Answers

Question -
How can we replace multiple spaces with a single space?



Answer -

We can cover tabs, newlines by using the following code:
string = string.replace(/\s\s+/g, ' ');

We can cover only spaces by using the following code:
string = string.replace(/  +/g, ' ');

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners