title: remove some text after - from string
body: <p>I want to remove some text from string or integer using javascipt or jquery..</p>
  
  <p>I have string <code>"flow-[s/c]"</code>, <code>"flow-max[s/c]"</code>,<code>"flow-min[s/c]"</code>, <code>"Usage-[s/c]"</code>, <code>"temperature"</code></p>
  
  <p>And I want for each :
  <code>"flow"</code>, <code>"flow-max"</code>,<code>"flow-min"</code>, <code>"Usage"</code>, <code>"temperature"</code></p>
  
  <p>As you can see. I want to remove all the data after <code>-</code> found expect <code>flow-max</code> and <code>flow-min</code></p>
  
  <p>What I am doing :</p>
  
  <pre><code>var legendName = $(textElement).text().toLowerCase().replace(" ", "-");
  </code></pre>
  
  <p>Taking the legend Name example :  <code>"flow-[s/c]", "flow-max[s/c]"</code></p>
  
  <pre><code>var displayVal = legendName.split('-')[0];
  </code></pre>
  
  <p>remove all the data after <code>-</code> found </p>
  
  <p>But I am not able to add condition for <code>flow-max</code> because at this case I will be having two <code>-</code> and two place like <code>flow-min-[s/c]</code></p>