Because without the start-of-line character (^) there can be anything at the beginning and as long as it ends in a number repeated three times, it will match. So you could have “42 42 42 42” or “hello world 6 6 6”, etc.
Gotcha. So it’s a best practices situation, but without it I wouldn’t get the desired result of “42 42 42”. it would have been “42 42 42 42”. Thank You Ariel.
It’s not so much a “best practices” as it is a matter of what you are looking for. Is you goal to make sure that the string is only a number repeated exactly 3 times? Then you need both ^ and $. Can you accept any string that ends with a number repeated 3 times? You only need $. Do you just care that it has a number repeated three times in a row somewhere in there? You want to omit both.