title: Do not delete all the keys of the localstorage
body: <p>In my application I would like that in a moment all the keys of my localstorage will be deleted, with the exception of all the keys that contain the word "wizard".</p>
  
  <p>Commands such as </p>
  
  <pre><code>localstorage.clear(); 
  </code></pre>
  
  <p>will erase everything, and I just want to keep those that have the word "wizard", I have tried in this way, but I get errors because if I delete a match, in the next iteration a key will be skipped, I will get the error that is trying to search a match in a position that will now be null, since it has been deleted. how can I solve that?</p>
  
  <p>this is my code:</p>
  
  <pre><code>for ( var i = 0, len = localStorage.length; i &lt; len; ++i ) {
    //if the key not contain the word "wizard" will be erased
    if( localStorage.getItem(localStorage.key(i)).search("wizard")==-1){
     localstorage.removeItem( localStorage.getItem( localStorage.key( i ) ) );
    }
  }
  </code></pre>