When you are having trouble with regex matching, and you are certain your regex is correct, then it's time to check exactly what's in the string you're matching. One trick is to do this:
say "-->$string<--";
Any trailing whitespace will be apparent:
-->hello world <---
And if there is a newline at the end of the string, you'll see something like this:
-->hello world
<--
Or if you want to reveal every character's ascii code, you can do this:
printf "%vd \n", $string;
--output:--
92.120.50.49.104.101.108.108.111
Edit: the printf applies ord() to the characters, so the printf is not limited to ascii characters.