title: Using regular expressions in shell script
body: <p>What is the correct way to parse a string using regular expressions in a linux shell script? I wrote the following script to print my SO rep on the console using <code>curl</code> and <code>sed</code> (not solely because I'm rep-crazy - I'm trying to learn some shell scripting and regex before switching to linux).</p>
  
  <pre><code>json=$(curl -s http://stackoverflow.com/users/flair/165297.json)
  echo $json | sed 's/.*"reputation":"\([0-9,]\{1,\}\)".*/\1/' | sed s/,//
  </code></pre>
  
  <p>But somehow I feel that <code>sed</code> is not the proper tool to use here. I heard that <code>grep</code> is all about regex and explored it a bit. But apparently it prints the whole line whenever a match is found - I am trying to extract a number from a single line of text. Here is a downsized version of the string that I'm working on (returned by <code>curl</code>).</p>
  
  <blockquote>
    <p>{"displayName":"Amarghosh","reputation":"2,737","badgeHtml":"\u003cspan title=\"1 silver badge\"\u003e\u003cspan class=\"badge2\"\u003e&amp;#9679;\u003c/span\u003e\u003cspan class=\"badgecount\"\u003e1\u003c/span\u003e\u003c/span\u003e"}</p>
  </blockquote>
  
  <p>I guess my questions are:</p>
  
  <ul>
  <li>What is the correct way to parse a string using regular expressions in a linux shell script?</li>
  <li>Is <code>sed</code> the right thing to use here?  </li>
  <li>Could this be done using <code>grep</code>? </li>
  <li>Is there any other command that's more easier/appropriate?</li>
  </ul>