Advertisement
Lodscripts

20190620 JescanellasScript Modified

Jun 20th, 2019
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function numcharsbetweenocc1and2ofApple() {
  2.  
  3. var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2");
  4.  
  5. var your_string = sheet.getRange("B2").getValues().toString();
  6.  
  7.  
  8. var appletree = [];
  9. var apple_length = "apple".length;
  10. var char_counter = 0;
  11.  
  12.  
  13. while ("B2" !== "") {
  14.  
  15. var apple = your_string.indexOf("apple", char_counter) + apple_length;
  16.  
  17. appletree.push(apple);
  18.  
  19. char_counter = char_counter + apple;
  20.  
  21.  
  22. var result = apple;
  23.  
  24. sheet.getRange("D2").setValue(result);
  25.  
  26.  
  27.  
  28.  
  29. if (char_counter >= your_string.length)
  30.  break;
  31.  
  32. };
  33. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement