So basically I use a program that lets you filter incoming text using regexs. It runs them off the PCRE library.
The incoming text I'm looking to filter comes in the form of
#K%<5 digit ID><3 digit character count><3 alpha literal><data>
i.e.
#K%00675011AAF3.0 days
The 5 digit ID is known ahead of time, the 3 digit character count is the length of the data + 3 for the alpha literal. The problem is that these sequences may or may not have a newline in front of them, and may or may not come in bunches with other text or other #K sequences, so what I'm trying to do is write a regex that will, by grabbing that 3 digit character count 'x', grab only the following 'x' characters after it. This appears to be way above my level of expertise as I'm guessing it needs to do some sort of look ahead?
Right now I'm grabbing as much as the regex will grab with (?:^)?\#K%(?:@MIP_ID)($count:\d{3})($literal:\a{3})($data:.*) and then using a right() style function to chop the data bit to a length of $count-3, then re-displaying the leftover chunk so the regex can grab it again. Is there a way to do something like (?:^)?\#K%(?:@MIP_ID)($count:\d{3})($literal:\a{3})($data:.{$count}) because that doesn't seem to compile...
Any help would be greatly appreciated.