Regex libraries often distinguish between a string containing a regex, and matching it.
The string "aaaa" is a Regular Expression that describes a language with exactly one string: "aaaa".
Some regular expression libraries have two operations: They can tell you if a string contains a match somewhere within it, or is exactly a match. Some other libraries only do the first operation, and you need to explicitly ask for "^aaaa$" to get an exact match.
This is one of the things on the differences between the formal definition of a Regular Expression, and a regex library.
The regex ^a$ only matches "a", but it doesn't match itself.