I have a Google Apps Script function which I want to use to do this: extract some data (a date) from a raw text in a spreadsheet cell. When I use a javascript IDE, the code works fine. But when I try it on GAS, it doesn't work.
This is the code:
function findDate (text){
text1 = text.split(".Date");
Logger.log("text1", text1);
//console.log("text1= ", text1);
date = 'no date informed';
for (var i=0; i<text1.length; i++) {
text2 = text1[i].split(" ");
Logger.log("text2", text2);
// console.log("text2= ", text2);
// console.log("text2[1]= ", text2[1]);
if (text2[1] === 'common:'){
date = text2[2];
Logger.log("text2[2]", text2[2]);
// console.log("text2[2]= ", text2[2]);
}
}
return date;
}
The string which is in the spreadsheet cell is not exactly this, it's writen in another language, but it's similar to this (broken text, but without the space between lines):
special term: 19 years, 6 months and 0 days.
commom term: 8 years, 8 months and 0 days.
Date special: 23/11/1998
Date common: 09/11/2012
When I get the logs, I got the message Logging output too large. Truncating output.
and this text:
[text1, [[special term: 19 years, 6 months and 0 days.
commom term: 8 years, 8 months and 0 days.
Date special: 23/11/1998
Date commom: 09/11/2012]]]
THANKS in advance for any help!