The regular expressions built into many programming languages have the semantics of matching any part of the string, not necessarily the whole string. If you want to match the whole string, you're supposed to put ^ at the beginning and $ at the end, or something like that.