> I want to write a regex to check if a whole string is a number. > With my current regex("[0-9]+") numbers will be carved out of things like > "aaa456" (hit: 456) and I circumvent this by checking the lengths for > inequality, which is stupid. My regex is surely missing something? Try ^ and $ if applicable. These match start and end of a line.