I have multiple flagged strings:
FLGSTdata1FLGEN FLGSTdata2FLGEN ...
FLGST is start flag and
FLGEN is end flag.
I combine those strings and add some garbage data, so it looks like this:
I need to get each of flagged strings from the combined strings.
Here is what I've done using
>>> pattern = r'5354([A-Za-z0-9_]*)454E' #FLGST = 5354 and FLGEN = 454E >>> data = re.findall(pattern,stringWithGarbage) >>> print data data1FLGENFLGSTdata2FLGENgarbagegarbageFLGSTdata3
It returns all data except the
FLGST of data1 and
FLGEN of data last.
So, how do you get each of flagged string from stringWithGarbage?
The appropriate return would be:
[data1, data2, data3, ...]