Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #10345
    user
    Participant

    hello!

    I need a macro that will delete all lines that match any of the regexes that are in a txt file (one below the other)

    is this possible?

    thanks!

    #10352
    user
    Participant

    I think I need to make it more clear:

    I am looking for a more convenient way than maintaining a list of:

    document.selection.Replace(โ€œ^455.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);

    I just want to have a list of the regex only and then the command to be the same

    thanks

    #10354
    user
    Participant

    instead of doing the below, is there a way to set a var with the numbers and use a single line?

    document.selection.Replace(โ€œ^918.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^919.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^920.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^921.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^922.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^924.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^925.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^926.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^927.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^928.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^929.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^946.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^972.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1093.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1109.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1166.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1185.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1188.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1189.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1190.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1191.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1192.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1193.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1194.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1196.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1198.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1200.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1223.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1436.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1438.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1439.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1440.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1441.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1442.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1443.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1444.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1466.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1469.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1636.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1637.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1638.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1640.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1641.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1648.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1650.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1862.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1871.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1872.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1874.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1875.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1883.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
    document.selection.Replace(โ€œ^1884.*$โ€, โ€œโ€, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);

    thanks

    #10357
    Stefan
    Participant

    If it allowed to match ANY number between โ€˜918โ€™ and โ€˜1884โ€™ ?

    Then try:



    for ( Numb = 918; Numb <= 1884; Numb++){
    document.selection.Replace("^" + Numb + ".*$", "", eeFindNext
    | eeFindReplaceRegExp | eeReplaceAll);
    }

    Or the showed numbers only?

    .

    #10358
    user
    Participant

    the shown numbers only
    also, in a way that the numbers list will be easily maintained, ie. add and remove entries
    thatโ€™s the difficult part :/

    #10361
    Stefan
    Participant

    Having e.g. โ€œc:tempnumbers.txtโ€ with one number at each line.

    c:tempnumbers.txt:

    123
    222
    345

    Use an code like this to read this file into an array.
    Then use a FOR loop to process each array indices (0 till highest index)
    and inside the FOR loop use the current index to do what you want.



    // 1.) helper code to read an files content

    //Your file with the numbers, each at an own line:
    NumbFile = "c:tempnumbers.txt";

    //============================================
    fso = new ActiveXObject("Scripting.FileSystemObject");
    oFile = fso.OpenTextFile(NumbFile, 1, false, 0);
    content = oFile.ReadAll();
    oFile.Close();
    fso = null;
    //alert(content);
    //============================================



    // 2.) the needed code itself
    //For Each Line In Lines Do:

    LinesArray = content.split("n");
    for (LineNumb = 0; LineNumb < LinesArray.length; LineNumb++){

    //do here what you want...
    bAnswer = confirm( LinesArray[LineNumb] );
    if (bAnswer == false){break;}

    }

    For more about Javascript FileSystemObject and text files read e.g.:
    http://www.ezineasp.net/post/Javascript-FSO-OpenTextFile-Method.aspx

    #10363
    user
    Participant

    great! thanks!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum โ€˜Questions and Answers about Macrosโ€™ is closed to new topics and replies.