Replacement for macro command Find Select to select a block between or with two found strings

Replacement for macro command Find Select to select a block between or with two found strings

6,686585
Grand MasterGrand Master
6,686585

    Oct 21, 2007#1

    Hello script writers!

    Do you miss the Find Select method in the script environment to select a block from current caret position to end of a found string, or to select a block between two strings as you can use it in the macro environment with the command Find Select "..." ?

    Yes, then look on the following two functions which I have developed to make this selection method also available in the script area.

    Perl experts would say that a Perl regular expression search string can do the same and that is often right and the better choice, but not always.

    If you want to report mistakes or have suggestions for further enhancements post a message here.

    The script file FindSelectInnerOuter.js with the code can be viewed or downloaded from the Macros & Scripts page.

    The line and block comments can be removed from functions FindSelectInner and FindSelectOuter by running a replace all (from top of file) searching with Perl regular expression for ^ *//.+[\r\n]+|^ */\*[\s\S]+?\*/[\r\n]+| +//.+$ and using an empty replace string. The first part in this OR expression with three arguments matches entire lines containing only a line comment, the second part matches block comments, and third part matches line comments right to code. Removal of the comments makes the usage of these functions in other scripts more efficient because of JavaScript interpreter has to interpret less characters and lines.

    25
    Basic UserBasic User
    25

      Oct 22, 2007#2

      Very slick! Thanks!

      6,686585
      Grand MasterGrand Master
      6,686585

        Aug 14, 2019#3

        The script file with the two functions FindSelectInner and FindSelectOuter was completely rewritten on 2019-08-14.

        The two functions work now for text files without any limitation with character encoding in
        • ANSI
        • UTF-8
        • UTF-16
        • ASCII Escaped Unicode
        with line endings in
        • DOS/Windows
        • Unix
        • Mac
        with regular expression engine being
        • Perl
        • UltraEdit
        • Unix
        for
        • non-regular expression
        • and regular expression
        search strings matching strings on
        • one line or
        • multiple lines
        with UltraEdit for Windows v13.10 and UEStudio v6.30 or any newer version.

        The rewritten functions contain code to determine after a positive find downwards on which line and column a found string (selection) begins and on which line and column a found string (selection) ends. Those code parts could be useful also for other scripts.

        The script file containing these two functions can be opened in UE/UES after download and executed to get demonstrated the usage of these two functions on an example HTML file created by the script temporarily.
        Best regards from an UC/UE/UES for Windows user from Austria

        74
        Advanced UserAdvanced User
        74

          Oct 23, 2019#4

          Mofi this is AWESOME! Thanks!