title: How do I remove a substring/character from a string in Scala?
body: <p>I am writing a program in which I need to filter a string. So I have a map of characters, and I want the string to filter out all characters that are not in the map. Is there a way for me to do this?</p>
  
  <p>Let's say we have the string and map:</p>
  
  <pre><code>str = "ABCDABCDABCDABCDABCD"
  
  Map('A' -&gt; "A", 'D' -&gt; "D") 
  </code></pre>
  
  <p>Then I want the string to be filtered down to:</p>
  
  <pre><code>str = "BCBCBCBCBC"
  </code></pre>
  
  <p>Also, if I find a given substring in the string, is there a way I can replace that with a different substring?</p>
  
  <p>So for example, if we have the string:</p>
  
  <pre><code>"The number ten is even"
  </code></pre>
  
  <p>Could we replace that with:</p>
  
  <pre><code>"The number 10 is even"
  </code></pre>