title: jQuery/JavaScript string replace a specific word and all characters after it
body: <p>How can I remove spaces, a keyword, and everything after it? Here's what I'm looking for</p>
  
  <pre><code>var test = $('.replaceMe').attr('title').replace(/ /g, '');
  
  &lt;a class="replaceMe" href="#" title="Replace By Everything After It"&gt;haha&lt;/a&gt;
  </code></pre>
  
  <p>resulting in:</p>
  
  <pre><code>test = Replace;
  </code></pre>
  
  <hr>
  
  <p>UPDATE:</p>
  
  <p>The keyword is a yet-to-be-determined word that will be included in all titles. In this example, it is "By".</p>
  
  <p>Both Roko and user1215106's answers work- in that they remove all the excess from the example, leaving Replace, but I failed to clarify that the phrase before the keyword (in this case, Replace) will vary and will have differing amounts of words.</p>
  
  <p>For example:</p>
  
  <pre><code>title="Replace By Everything After It"
  
  Result= Replace
  
  title="All This Should Stay By Things That Should Go"
  
  Result= AllThisShouldStay
  </code></pre>