Search for 2 values, output the 2nd, with unknown number of lines between

Search for 2 values, output the 2nd, with unknown number of lines between

15
Basic UserBasic User
15

    May 10, 2019#1

    I need to do a particular search on several hundred files, and output the file name and search results into a separate file or window. The files are all in one folder, and range in size from 45 KB (under 1000 lines of text) to over 19 MB (almost 400,000 lines).

    Here's the tricky part: I need to search for a particular string, then find the first occurrence of a different string after that (about 100 lines later, but can't guarantee that number), and output that second line.

    Any thoughts on how to accomplish that? I'm not averse to using JavaScript, Perl, regular expressions, etc., but am not an expert in any of that.

    I've attached a sample of the text I'm searching for.

    For every file, I need to find the line that contains "Name                                          CG$AN" (line 13 in the sample text), but output the first line it after that has "Hint" (line 104).

    Thanks,
    Dan
    Search Example.txt (5.08 KiB)   0

    18572
    MasterMaster
    18572

      May 10, 2019#2

      Hi,

      maybe this Perl regex will work for you. I know it is not the optimal one - Quick'n'Dirty (tm)  :)
      Name                                          CG\$AN(?s:.*?)^\K[ \t*]+hint\b.*$

      Use Find in Files, check Result to edit window ON, show 0 lines before and 0 lines after.
      The result will need some parsing but it should be a simple task. Or post here your desired format and I'll prepare the rest.

      BR, Fleggy

      15
      Basic UserBasic User
      15

        May 14, 2019#3

        Thanks, Fleggy. That did the job.