There might be some messengers that might have support for that, but they would only work for messages that are sent to/from/through them essentially, not for regular text messaging, or iMessage or anything like that.
There might also be some jailbreak tweaks that would allow for something like that when it comes to regular text messaging and iMessage, but I'm not sure if they really exist (and you'd have to be jailbroken for those too, if they do exist).
That aside, what you are talking about is similar to rules/filters that are generally part of email. It doesn't seem like something like that has crossed over into the world of messaging.