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)
  • You must be logged in to reply to this topic.