I have a text with Shamsi date like this:
Pathology report on 01.09.1402 (22.11.2023): Baso-squamous carcinoma in right thigh skin.
Surgical pathology report on 30.03.1403, Multiple lymphoid tissue involved by metastatic epithelial tumor of right inguinal mass.
I want to extract all the dates in an array.
How would you do that?
So far we have this:
const text = `Pathology report on 01.09.1402: Baso-squamous carcinoma in right thigh skin. Surgical pathology report on 30.03.1403, Multiple lymphoid tissue involved by metastatic epithelial tumor of right inguinal mass.`
console.log(getDate(text));
function getDate(d) {
var day, month, year;
result = d.match("[0-9]{2}([-/ .])[0-9]{2}[-/ .][0-9]{4}");
if (null != result) {
dateSplitted = result[0].split(result[1]);
day = dateSplitted[0];
month = dateSplitted[1];
year = dateSplitted[2];
}
result = d.match("[0-9]{4}([-/ .])[0-9]{2}[-/ .][0-9]{2}");
if (null != result) {
dateSplitted = result[0].split(result[1]);
day = dateSplitted[2];
month = dateSplitted[1];
year = dateSplitted[0];
}
if (month > 12) {
aux = day;
day = month;
month = aux;
}
return `${day}.${month}.${year}`;
}