Let's say I have a string that represents a list of unique key/value pairs like so:
a:1;b:2;c:3;d:4
Checking whether the string contains a specific key/value pair is straight forward. But let's say I want to take advantage of the fact that the keys are unique. Is there a way to optimize the regex so that if it finds a key with a value different than the one I want, it immediately fails rather than continue scanning to the end of the string?
So, in the example above, if I want to see if b:3 is in the string, I'd want the match to fail as soon as it finds b:2. (note: an inverse search for something like b:[^3] isn't going to work for cases where they key b is missing)