To be considered text files having repeated structures. These structures possess repeated start delimiter, optional stop delimiter and variable contents. That is some or all fields of these structures are optional. A task is to select all whole structures, that contain a specified pattern. This can be done using a multiline regular expressions. But there is a performance issue: Processing time using regular expression is not directly proportional to amount of structures, so that increasing of this amount might cause the reqular expression will never finish. Processing time of the proposed function is directly proportional to amount of structures.