...as a read filter or a display filter, not a capture filter.
Capture filters can't be implemented with loops, as in-kernel cBPF interpreters don't allow backwards branches, so any loop looking for some data in any position in a packet, or any position within a field of a packet, would have to be completely unrolled, which is a bit difficult if the size of the area to be checked isn't known at the time the filter expression is compiled into code.
Capture filter or display filter?
6.3. Filtering Packets While Viewing
I mean capture filter
Capture filters at arbitrary locations in the data are tough.
There are some notes here:
String-Matching Capture Filter Generator