in reply to Re: Regex to select multiple lines
in thread Regex to select multiple lines

this is the data I'm trying to extract from. Apologies for the lack of code tags in the previous post
Message Type: DeleteSubscriber Request Text: <?xml version="1.0" encoding="UTF-8"?><msg> <head> + <RoundTripInfo>DeleteSubscriber</RoundTripInfo> </head> <b +ody> <HostIdentifier> <VendorID>CSGSYSTEMS</VendorI +D> <SiteIdent>877400000000</SiteIdent> </HostIdenti +fier> <DeleteSubscriber> <BSSubscriberKey>123000000 +0000002</BSSubscriberKey> <ExternalStatus>Voluntary Discon +nect</ExternalStatus> </DeleteSubscriber> </body></msg> Response Text: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <msg><head><RoundTripInfo>DeleteSubscriber</RoundTripInfo></head><body +><ClientIdentifier><CVendorID>JacobsRimell-APS</CVendorID><SiteIdent> +CSGListener</SiteIdent></ClientIdentifier><Stdmsgresp><ErrorCode>0000 +0</ErrorCode><ErrorMsg>Delete Subscriber: Subscriber is in abuse stat +e</ErrorMsg><SuggestedAction/></Stdmsgresp></body></msg> Error Code: 00000 Transaction Time: 133

What I'm trying to do is lift the Error Code, Transaction Time and Message Type from the log file. The number of lines varies from each block that I'm matching.
Thanks

Replies are listed 'Best First'.
Re^3: Regex to select multiple lines
by Animator (Hermit) on Dec 09, 2004 at 16:07 UTC

    Did you consider reading the file all at once in a plain scalar?

    If you really want to process the file/array line by line then you can add a while loop in your if-statement that does something (or maybe nothing if you don't need the lines) with the data of those line.