0

every day I received this kind of email is automatically generated my goal is a regular expression or scripting code to select all the text between two outer brackets.

example: test test test (a) (b) (aaaaa ( bbbb (cccc)) dddd (ee) fff) test test test

result :(a) (b) (aaaaa ( bbbb (cccc)) dddd (ee) fff)

this is the body Email:

All documents are reproduced with the permission of the copyright owner. Further reproduction or distribution is prohibited without permission. Please do not reply directly to this email. ProQuest Search alert ProQuest Dialog will send alerts Daily to: Email address: productcostumer@sap.com Alert name: Competitors Alert ID: 560083 Dates of coverage: March 15 2018 through March 16 2018 Created by My Research account: Jack(Smith Jack)

Subject: (ti,ab(((Abbott near/10 (assay* OR test* OR analy* OR array)) OR (Abbott p/1 Point P/1 Care) OR ARCHITECT OR (CELL p/0 DYN)) OR ((Alere near/10 (assay* OR test* OR analy* OR array)) OR (Alere NEAR/5 (Triage P/1 System)) OR INRatio OR Afinion) OR ((Beckman* p/1 Coulter near/10 (assay* OR test* OR analy* OR array)) OR ((Beckman* p/0 Coulter) near/2 AU????) OR (UniCel* P/1 DxC) OR (UniCel* p/1 DxI) OR ( Beckman* near/5 Access) OR (Access* p/1 Systeme) OR (CytoFLEX OR (cyto p/0 flex)) OR (UniCel* p/1... Alert keywords: Competitors

at ProQuest Dialog. See documents in available formats (e.g., Citation/Abstract, Full text, etc.). Export documents to PDF, RTF, XML, etc.

1 new documents found for (ti,ab(((Abbott near/10 (assay* OR test* OR analy* OR array)) OR (Abbott p/1 Point P/1 Care) OR ARCHITECT OR (CELL p/0 DYN)) OR ((Alere near/10 (assay* OR test* OR analy* OR array)) OR (Alere NEAR/5 (Triage P/1 System)) OR INRatio OR Afinion) OR ((Beckman* p/1 Coulter near/10 (assay* OR test* OR analy* OR array)) OR ((Beckman* p/0 Coulter) near/2 AU????) OR (UniCel* P/1 DxC) OR (UniCel* p/1 DxI) OR ( Beckman* near/5 Access) OR (Access* p/1 Systeme) OR (CytoFLEX OR (cyto p/0 flex)) OR (UniCel* p/1 DxH) OR ((Coulter* p/1 LH) OR CoulterLH)) OR ((Ortho p/0 Clinical P/1 Diagnostics) OR VITROS OR (vitros p/1 System*) OR (VITROS* p/1 ECiQ) OR ORTHOTM OR (orthotm p/1 VISION) OR (ORTHO p/1 AutoVue*)) OR ((Instrumentation p/0 Laboratories) OR HemosIL OR ACLTOP OR (ACL p/0 ELITE) OR (GEM* P/1 Premier) OR GEMOPL) OR ((Radiometer near/10 (assay OR test* OR analy* OR array)) OR (AQT?? p/0 FLEX) OR (ABL?? p/0 FLEX) OR HemoCue*) OR ((Nova p/0 Biomedical) OR StatStrip OR (STAT p/0 PROFILE*) OR ((Nova p/0 Biomedical) near/1 Prime) OR STATPROFILE*) OR (((Siemens p/0 Healthcare) near/10 (assay* OR test* OR analy* OR array)) OR (ADVIA p/0 Centaur) OR (Dimension p/0 Vista) OR RAPIDPOINT))) and (ud(>20170101)) (see attachment)

All ProQuest Dialog alert emails are sent from: alert@proquest.com. Tip: use this email address to set up a filter and direct ProQuest Dialog alert mail to a folder other than your inbox.

this is my script code:

var messageBody = message.getPlainBody();
var ssFile = DriveApp.getFileById(id);
DriveApp.getFolderById(folder.getId()).addFile(ssFile);
var ss = SpreadsheetApp.open(ssFile);
var sheet = ss.getSheets()[0];
sheet.insertColumnAfter(sheet.getLastColumn());
SpreadsheetApp.flush();
var sheet = ss.getSheets()[0];
var range = sheet.getRange(1, 1, sheet.getLastRow(), sheet.getLastColumn() + 1)
var values = range.getValues();
values[0][sheet.getLastColumn()] = "Search Strategy";
for (var i = 1; i < values.length; i++) {

var y = messageBody.match(/\((.*)\)/ig); //my regexp to extract the the text between ()
if (y)



   values[i][values[i].length - 1] = y.toString();
    }
range.setValues(values);

this result that i expected :

(ti,ab(((Abbott near/10 (assay* OR test* OR analy* OR array)) OR (Abbott p/1 Point P/1 Care) OR ARCHITECT OR (CELL p/0 DYN)) OR ((Alere near/10 (assay* OR test* OR analy* OR array)) OR (Alere NEAR/5 (Triage P/1 System)) OR INRatio OR Afinion) OR ((Beckman* p/1 Coulter near/10 (assay* OR test* OR analy* OR array)) OR ((Beckman* p/0 Coulter) near/2 AU????) OR (UniCel* P/1 DxC) OR (UniCel* p/1 DxI) OR ( Beckman* near/5 Access) OR (Access* p/1 Systeme) OR (CytoFLEX OR (cyto p/0 flex)) OR (UniCel* p/1 DxH) OR ((Coulter* p/1 LH) OR CoulterLH)) OR ((Ortho p/0 Clinical P/1 Diagnostics) OR VITROS OR (vitros p/1 System*) OR (VITROS* p/1 ECiQ) OR ORTHOTM OR (orthotm p/1 VISION) OR (ORTHO p/1 AutoVue*)) OR ((Instrumentation p/0 Laboratories) OR HemosIL OR ACLTOP OR (ACL p/0 ELITE) OR (GEM* P/1 Premier) OR GEMOPL) OR ((Radiometer near/10 (assay OR test* OR analy* OR array)) OR (AQT?? p/0 FLEX) OR (ABL?? p/0 FLEX) OR HemoCue*) OR ((Nova p/0 Biomedical) OR StatStrip OR (STAT p/0 PROFILE*) OR ((Nova p/0 Biomedical) near/1 Prime) OR STATPROFILE*) OR (((Siemens p/0 Healthcare) near/10 (assay* OR test* OR analy* OR array)) OR (ADVIA p/0 Centaur) OR (Dimension p/0 Vista) OR RAPIDPOINT)))

the wrong Parse:

(Smith Jack),(ti,ab(((Abbott near/10 (assay* OR test* OR analy* OR array)),(Abbott p/1 Point P/1 Care) OR ARCHITECT OR (CELL p/0 DYN)),(assay* OR test* OR analy* OR array)),(assay* OR test* OR analy* OR array)) OR ((Beckman* p/0 Coulter),(UniCel* P/1 DxC) OR (UniCel* p/1 DxI),(Access* p/1 Systeme) OR (CytoFLEX OR (cyto p/0 flex)),(Abbott p/1 Point P/1 Care),((Alere near/10 (assay* OR test* OR analy* OR array)),(Alere NEAR/5 (Triage P/1 System)) OR INRatio OR Afinion),(assay* OR test* OR analy* OR array)),(UniCel* P/1 DxC) OR (UniCel* p/1 DxI),(Access* p/1 Systeme),(UniCel* p/1 DxH) OR ((Coulter* p/1 LH) OR CoulterLH)),((Ortho p/0 Clinical P/1 Diagnostics) OR VITROS OR (vitros p/1 System*),(VITROS* p/1 ECiQ) OR ORTHOTM OR (orthotm p/1 VISION),((Instrumentation p/0 Laboratories),(ACL p/0 ELITE) OR (GEM* P/1 Premier) OR GEMOPL),(assay OR test* OR analy* OR array)) OR (AQT?? p/0 FLEX),((Nova p/0 Biomedical),((Nova p/0 Biomedical) near/1 Prime) OR STATPROFILE*),(((Siemens p/0 Healthcare) near/10 (assay* OR test* OR analy* OR array)),(ADVIA p/0 Centaur) OR (Dimension p/0 Vista) OR RAPIDPOINT))),(ud(>20170101)) (see attachment)

Any help will be gratefully received

Moka
  • 83
  • 7
  • RE can't match that. You need a pushdown automata. See https://stackoverflow.com/questions/546433/regular-expression-to-match-outer-brackets https://stackoverflow.com/questions/524548/regular-expression-to-detect-semi-colon-terminated-c-for-while-loops/524624#524624 – Dan D. Mar 20 '18 at 10:34
  • but this question was 9 years ago.. now there is new version for RE – Moka Mar 20 '18 at 10:37
  • @Moka I believe JavaScript still lacks this feature (recursion). – O.O.Balance Mar 20 '18 at 12:49

0 Answers0