Reputation: 145
Good morning. I have the following line returned from a device
♥☺i20100☺i2010018032809120110000074653B0F4465275D245EAA80042D82F5E000000004291D83C00000000022000007460042FD45FE7F2A4648C0004282FC0400000000429799E500000000033000007466A869946694E8145BCF80042EF811B00000000428CCAF400000000044000007461DFFC4461D1D61462B040042A15A6600000000428E635100000000&&C631♥
The data comes back in blocks of 6 characters after the date-time stamp. I'm trying to get past the date-time and look for all blocks of 6 that begin with 42. There should be 3 blocks returned.
Using Expresso, I can get all the blocks of .*i20100.i20100(?<Date>.{10})(?<AANNTT>.{6})+
but how can I make a subquery on each of those and return all the ones starting with 42? I thought it might be this: .*i20100.i20100(?<Date>.{10})(.{6})*(?<AANNTT>42.{4})+
but that's only returning the last one.
Thanks in advance! -Dave
Upvotes: 1
Views: 53
Reputation: 626738
You may use
(?<=i20100.i20100(?<Date>.{10})(?:.{6})*?)42.{4}
See the regex demo
Details
(?<=i20100.i20100(?<Date>.{10})(?:.{6})*?)
- a positive lookahead that matches a location in a string that is immediately preceded with
i20100.i20100
- i20100
, and char but a newline, i20100
(?<Date>.{10})(?:.{6})*?
- Group Date
that matches 10 chars other than a newline, then any 0+ repetitions of any 6 chars but a newline, as few as possible42.{4}
- 42
and then any 4 chars other than a newlineUpvotes: 1