Can you test for a player whose score does *not* equal a given number in Minecraft?

In Minecraft, is it possible to test for a player whose score does not equal, say, 5 (i.e. if their score is less than 5, greater than 5, or null)?


Big edit to this answer, because 1.13 added a way to directly do this:

/execute as @a unless score @s <score> matches <value> run <command>

Not directly. You could use 2 commands, one to test if the score is lower and one to test if the score is higher. But this doesn't work for "null".

Instead, I usually just test if the score is 5 and invert the signal using scoreboard tags (or a comparator + redstone torch).

An example:

/scoreboard players tag @a[tag=!not5] add not5

/scoreboard players tag @a[score_objectiveName_min=5,score_objectiveName=5] remove not5

Only players who don't have a score of 5 for objectiveName will have the not5 tag