I want to match based on a pattern that has a string that can contain the literal '.' I'm fed a steady stream of input strings, and I don't know in advance anything about them.
Inputs could be, for example: myexample.txt, dog, 1476.2.6, mail.yahoo.com, larry, etc.
For each different string I need to construct a pattern for it.
In other words, I want something which says: match this string
literally, no matter what characters it has. Maybe more specifically: match this string of N characters literally, from N=strlen(input);
I realize that I can grossly deal with this issue by copying over the string and whenever I see a "." (or other special character) first escaping it. Then sprintf(pattern_buf, " .... %s ... ", ..., massaged_input, ...);
But, there must be a slicker way of doing it. One that doesn't rely on my examining and perhaps massaging each input string as it arrives. The ways I've tried have failed.
( There's more to it than this. This is an inner string and it only
forms part of of the RE. I'm given the other parts separately, but they
can contain only alphanumerics. All the fields are separated by '.', which
I add myself. This may seem to lead to ambiguity of the '.' as both being a field separator as well as character in a field name. But the known positioning of the various fields eliminates this as a problem.)