title: I want to select just string before comma
body: <p>I want to select whole word until a comma comes. If a comma is there in paragraph this should be not shown. Also, if I select text half it should show the complete word. </p>
  
  <pre class="lang-js prettyprint-override"><code>jQuery(document).ready(function() {
    $("#content &gt; div.row &gt; div &gt; p:nth-child(10)").click(function() {
      var s = window.getSelection();
      s.modify('extend', 'backward', 'word');
      var b = s.toString();
  
      s.modify('extend', 'forward', 'word');
      var a = s.toString();
      s.modify('move', 'forward', 'character');
      $(".location-selected").remove();
      $("#content &gt; h2").append('&lt;div class="location-selected"&gt;you have selected 
        location '+(b+a)+' &lt; /div&gt;');
      });
    });
  </code></pre>
  
  <p>Here is my line:</p>
  
  <pre><code>Gqaka, Gqaqala, Gqiba, Gqobonco, Gqogqora, Gqola, Gqoloma, Gqora, Gqubeni, Gqubonco, Gqukangqa, Gquk
  </code></pre>
  
  <p>If I click on <code>Gqiba</code> it should show just this word. If I drag with mouse selection <code>Gqiba, Gqobonco</code> it should get just one word before comma. This means it should get <code>Gqiba</code> - it should ignore <code>Gqobonco</code>. Also if I select <code>iba</code> from mouse selection it should show full word which is <code>Gqiba</code> it should not select just <code>iba</code> and show. Kindly help me.</p>