I was recently asking a question about inverse matching with regex, and stumbled onto inverse-match. It's got no usage guidance (maybe that's what it needs?) and isn't commonly added to posts.
Inverse matching is where a regular expression (regex) or other pattern-searching engine "matches" everything but the specified pattern. There's six questions that use this tag, and only one that seems to have amassed significant views; ironically, several answers on this popular question imply inverse matching isn't something regex does well. Burnination was my first thought, but I'm not sure if sparsely-used tags are supposed to be removed just for that reason, and I'm also not sure it fails all of the requirements.
- Does it describe the contents of the questions to which it is applied? and is it unambiguous?
Yes and not really. It certainly describes the contents of the question, and seems to be "often" used as regex-related. I'm not sure if it qualifies as unambiguous, though, given that there's several ways to inverse match but regex itself (a widely used matching engine) doesn't have built-in support for this. Furthermore, it's implied that inverse-matching is best left to the programming language, not the regex, but the questions seem to evenly hand it to both regex and whatever language it's being used with.
- Is the concept described even on-topic for the site?
Certainly seems to be; inverse matching is not natively supported in regex, but it's usually very easy to implement in several programming languages.
- Does the tag add any meaningful information to the post?
It describes what the user wants to do, but aside from making the post easier to find, it doesn't add meaningful information as far as I can see. (I'm not sure if "making the post easier to find" IS the meaningful information - if so, please let me know.)
- Does it mean the same thing in all common contexts?
Along with the unambiguous requirement, this is what prompted me to ask about the tag. The behavior is the same in all contexts, but it's not well-defined for regex, which seems to be the most common one. Although it's easy to emulate, inverse matching isn't really fully supported in the (brief) look through languages I did, either. It seems to be mostly facilitated by use of normal matching and then some form of split()
function, to first find the un-desired match and then get the parts of the string left over from it. Inverse matching can be inefficient at best and dangerous at worst to try and pull off with a regex alone, due to the potential for catastrophic backtracking (accidental O(n^2) search time).
What should be done in a situation like this?