title: How to trim and replace string in TypeScript?
body: <p>I have a single string with spaces. Like "Dmitry Vladimirovich Nikitin". My task is to trim a string and replace all spaces with '\n'.</p>
  
  <p>So, as a result I will get:</p>
  
  <p>Dmitry \n
  Vladimirovich \n
  Nikitin \n</p>
  
  <pre><code>var FIO = nameEmployer
  
  console.log(nameEmployer.trim())
  
  FIO = FIO.trim()
  
  FIO = FIO.replace(/ /g, '\n')
  </code></pre>
  
  <p>As you see, I used '/ /g' expression here to replace all the spaces with '\n'.</p>
  
  <p>But 1 single string (Dmitry Vladi Nikitin) appeared. </p>
  
  <p><a href="https://i.stack.imgur.com/LCleU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LCleU.png" alt="enter image description here"></a></p>
  
  <p>What's the problem?</p>