I'm new to regular expressions, and I need to write a set of regular expressions that match different data packet formats.
My problem is, usually I only need to look for the start and ending parts of the packet to distinguish between them, the data in between is irrelevant.
What's the most efficient way to ignore the data between the start and end?
Here's a simple example. The packet I'm looking for starts with $CH; and ends with #
Currently my regex is \$CH;.*?#
It's the .*? I'm worried about. Is there a better (or more efficient) way to accept any character between the packet header and ending character?
Also, some of the packets have \n chars in the data, so using . won't work at all if it means [^\n].
I've also considered [^\x00]*?
to detect any characters since null is never used in the data.
Any suggestions?