July 16th, 2013, 09:15 PM
Is the text stored in file?
Is it formatted exactly how you have posted it?
What language do you use for this?
If the first two questions above is an yes, regex is not required for this.
Most (all?) languages have function to read a file line by line.
1. Read each line until you find a line with ZZZ
2. When ZZZ is found, read and save all following lines
2a. If line contains KKKK, register that it does exists.
3. Stop when line contains NNN
4a. If KKK exists, process the saved data as needed.
4b. If KKK doesn't exists, repeat from 1.