On Sat, 7 Nov 2020, Brian Vogel wrote:
[Regarding my question about the use of \s?]
My thinking it that there can be no whitespace after the colon, or an instance of a single whitespace character, but not multiple whitespace characters.Are you sure? Just using egrep -e on my local machine, all of the following expressions will match the string "test":
I agree that one could probably use \b, but I was thinking "whitespace" and used whitespace matching.I understand why whitespace might be interesting there. But searching for it as optional, without an anchor or pre/post text, is the same as not searching for it at all.
It is an old truism in regex building, that if your match potentially includes zero of something at the start or end of an expression, it may as well not be there unless there is an anchor.
For example, my tests above, rewritten as:
would fail as they should. But the naked zero space matches in the originals function exactly as a full wildcard (.*).