Hint: this'd work a lot better if levelstr were declared varchar() ortext. The padding spaces for char() are messing up your match pattern.
regards, tom lane