JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
870 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
i am trying to retrieve values from below strings using Regular Expression in JavaScript. would you be able to help me out please? it would be separate value for Project Number, Project Name, Insurance Type and the Date.
001196 - La Cabana - Ins Boiler and Machinery – 6/1/21.pdf
Var Project Number= 001196
Var Project Name= La Cabana
Var Insurance Type= Ins Boiler and Machinery
Date= 6/1/21
so far i was able to retrieve Project number using below JavaScript. same way i need to retrieve project name, insurance type and Date without hyphens ad pdf.
if (Fidelity == "Ins Fidelity"){
var projectNumber = fileName.substring(0,6);
}
const regex = /[^0-9]/g;
projectNumber = projectNumber.replace(regex, "");
builder.SetDocumentMetadata(doc.DocumentId, "Index", "ProjectNumber", projectNumber);
}
Thanks in advanced!!