title: Regular expression with JavaScript URL redirect
body: <p>I was trying to redirect IE8 (and downwards) to a different page. I currently have the following: </p>
  
  <pre><code>&lt;!--[if lt IE 9]&gt;
     &lt;script type="text/javascript"&gt;
       var oldURL = document.location.href;
       var code = url.slice(-3);        
       window.location = "http://www.example.com/" + code;
    &lt;/script&gt;
  &lt;![endif]--&gt;
  </code></pre>
  
  <p>Of course this works if an IE8 visitor is on the address:</p>
  
  <p><a href="http://www.example.com/index.htm#!/ABC" rel="nofollow">http://www.example.com/index.htm#!/ABC</a></p>
  
  <p>but not if they're at: </p>
  
  <p><a href="http://www.example.com/index.htm#!/ABC/subpage" rel="nofollow">http://www.example.com/index.htm#!/ABC/subpage</a>  or <a href="http://www.example.com/index.htm#!/ABC/subpage/anotherpage" rel="nofollow">http://www.example.com/index.htm#!/ABC/subpage/anotherpage</a></p>
  
  <p>The code I want is always following a #!/ but I cannot control what trails it. </p>
  
  <p>I went after some regular expression help here: <a href="http://txt2re.com/index-javascript.php3?s=http://www.example.com/index.htm%23!/ABC&amp;18" rel="nofollow">http://txt2re.com/index-javascript.php3?s=http://www.example.com/index.htm%23!/ABC&amp;18</a> but the solution seems a bit flakey if the URL structure changes in the future. </p>
  
  <p>I expect the output ABC in each of the examples above. </p>
  
  <p>What's the next step here? I would like to understand the most stable solution. </p>