> Can't one do that with regex?
You can, but it doesn't make the solution any simpler: while (!s.matches("hi"))
The "pure" regex version would be while (s.matches("(?!hi$).*"))
One of the most annoying shortcomings of regexes is that they make it so difficult to express such a simple concept.