Tapatalk

How to find with Find in Files a string within a certain column range?

How to find with Find in Files a string within a certain column range?

1
NewbieNewbie
1

    Jan 05, 2018#1

    Hi,
    Does anyone have any advice on how I would go about accomplishing the goal I have below:

    What I would like to do is, search in 2 files at once. However, when I do that I need to be searching within a certain column range. I know this part is possible on the Find tab. The issue I am having is that I would like the find results to be exported to a new window, which I know is possible in the find in files tab. What is not possible, or at least I am not sure about, is searching within a set column range under find in files.

    Does anyone know how I could get that information exported? If there is not a way to export it, is there a way to highlight all of the found data at once instead of hitting next each time?

    If this is not clear enough, I would be happy to provide screen shots or anything else you might need.

    6,685587
    Grand MasterGrand Master
    6,685587

      Jan 05, 2018#2

      You can use a regular expression Find in Files to find all lines in all files containing a string at a specific column or within a specific column range.

      For example a file contains following three lines:

      12b45a7890
      12345b7890
      12345c78b0

      And found should be only the lines containing character b at column 6. This can be done with:

      UltraEdit regular expression engine searching for: %?????b

      % ... start of line.
      ????? ... 5 characters except newline characters like carriage return and line-feed.
      b ... the character b after 5 other characters from start of line, i.e. at column 6.

      Unix or Perl regular expression engine searching for: ^.....b

      ^ ... start of line.
      ..... ... 5 characters except newline characters like carriage return and line-feed.
      b ... the character b after 5 other characters from start of line, i.e. at column 6.

      Perl regular expression engine searching for: ^.{5}\Kb

      ^ ... start of line.
      .{5} ... any character except newline characters exactly 5 times.
      \K ... resets the start location to the current text position. In other words everything to the left of \K is "kept back" and does not form part of the regular expression match.
      b ... the character b after 5 other characters from start of line, i.e. at column 6.

      \K results in getting selected just b at column 6 without the 5 other characters before. A Find in Files always reports the entire line containing found string. Therefore \K is not really useful in this case and can be omitted from search string.

      It is also possible to search for b in a column range very easily with most powerful regular expression engine Perl. For example to find all lines in all files as specified in Find in Files containing b somewhere in columns 3 to 6, the search string to use is either ^.{2,5}\Kb or just ^.{2,5}b. This expression means at least 2 but not more than 5 characters except newline characters should be found at start of a line before character b must be found next for a positive match.
      Best regards from an UC/UE/UES for Windows user from Austria