vrijdag 15 november 2019

split() here, split() there, split() everywhere

This morning I woke up and thougth that there must a better way (then this one) to scrape large strings. While walking on my way to my work (more than an hour) I had my eureka moment.

It works, at least in case of unique splitter-strings.

function testStringSplitter(){
  
  var url = "https://www.raadvanstate.nl/uitspraken/@117938/201809034-1-v3/";
  var myNotSoFavoriteString = UrlFetchApp.fetch(url).getContentText(); 
  var splitters = [["advocaat te Den Haag",1],["eisen van artikel 2:16, eerste lid, van de Awb",1],["verklaart het hoger beroep ",1],[";",0]]
  
  var decision = stringSplitter(myNotSoFavoriteString,splitters);
  
  //decision = gegrond (founded) 
  
}


function stringSplitter(string,splitters) {
  var s=0;
  while(s<splitters.length){
    var splitter = splitters[s];
    string = string.split(splitter[0])[splitter[1]];
    s++
  }
  return string;
}

My client was already released.

Geen opmerkingen:

Een reactie posten