title: how to get the base url using regex in javascript
body: <p>My app is going to work in multiple env, in which i need to get the common value (base url for my app) to work across..</p>
  
  <p>from my window location how to i get certain part from the start..</p>
  
  <p>example :</p>
  
  <pre><code>    http://xxxxx.yyyy.xxxxx.com:14567/yx/someother/foldername/index.html
  </code></pre>
  
  <p>how can i get only:</p>
  
  <pre><code>http://xxxxx.yyyy.xxxxx.com:14567/yx/
  </code></pre>
  
  <p>my try :</p>
  
  <pre><code>var base = \w([yx]/)
  </code></pre>
  
  <p>the base only select <code>yx/</code> how to get the value in front of this?</p>
  
  <p>this part..</p>
  
  <p>thanks in advance..</p>