title: Get substings between Specific Characters
body: <p>I am trying to solve some JS problem. I want to check if an IP address is a valid one. 
  So the numbers must be between 0-255. </p>
  
  <p>So what I want to do at this point, is to get an IP ex 192.168.1.1 and get substrings and load them to an array, so I want to create an array that looks like that: </p>
  
  <pre><code>array = ['192' , '168' , '1' , '1'];
  </code></pre>
  
  <p>I've tried various approaches in my algorithm but can't manage to target dynamically the numbers and split them between every dot.</p>
  
  <p>I've done several tries, and thats the closest I could get.</p>
  
  <pre><code>let str = '192.168.1.1';
  
  isValidIp(str);
  
  function isValidIP(str) {
  let array = [];
  let substringArray = [];
  for (let i=0; i&lt;str.length; i++){
  
  if (str[i] == '.') array.push(i);
  
  }
  
  let counter = 0;
  for (let i in array){
  substringArray.push(str.substring(counter, array[i]));
  counter = array[i];
  }
  console.log(substringArray);
  }
  
  
  </code></pre>
  
  <p>Which returns:</p>
  
  <pre><code>[ '192', '.168', '.1' ]
  </code></pre>