Hi NotPad001 and All,
Ah ! I understood why the regex does not match the 2nd section with GENDER=MALE Don’t you see it ? Well, seemingly, from your picture, the last line ( line 25 ) does not end with a colon character ! And it’s obvious that searching from GENDER=FEMALE sections worked perfectly right ;-))
So the correct regex to process is :
SEARCH (?s-i)^STARTDATA:\R(?-s:.*\R){0,3}GENDER=MALE.+?^ENDDATA:?
I just added a regex question mark symbol ( ? ), which is a shorthand of the {0,1} quantifier, at the end of the regex
BTW, note that, if the line GENDER=.... is located right after the STARTDATA: line, you may simply use the shorter regex :
SEARCH (?s-i)^STARTDATA:\RGENDER=MALE.+?^ENDDATA:?
Now, there are a lot of methods to filter out your text : Let’s suppose that you want to keep sections with GENDER=MALE, only :
First, you could use an option from the Bookmark menu ( Search > Bookmark )
Bookmark sections containing GENDER=MALE, with the appropriate regex and, then, use the option Search > Bookmark > Remove Unmarked lines
Bookmark sections containing GENDER=FEMALE, with the appropriate regex and, then, use the option Search > Bookmark > Remove Bookmarked lines
Secondly, you could use one of the two regex S/R, below, ( Ctrl + H ), directly, searching for GENDER=FEMALE sections and clicking on the Replace All button :
SEARCH (?s-i)^STARTDATA:\RGENDER=FEMALE.+?^ENDDATA:?\R?
REPLACE Leave EMPTY
SEARCH (?s-i)^STARTDATA:\R(?-s:.*\R){M,N}GENDER=FEMALE.+?^ENDDATA:?\R?
REPLACE Leave EMPTY
Remark that, in order to delete the entire lines ENDDATA:, we need to add the part \R? at the end of the regexes to match the line-break of lines ENDDATA(:) too, which is optional, in case that the very last line of your file is not followed with a line-break !
Best regards,
guy038