add pattern priority, longer pattern will be tagged at first while the shorter will not be tagged.