You're looking for:
If you want a positive number without leading zeros, use
If you don't care about whitespaces around the number, you can also try:
Note that you don't want to allow partial matching, for example 123abc, so you need the start and end anchors: ^...$.
Your regex has a common mistake: ^\s*|\d+$, for example, does not enforce a whole match, as is it the same as (^\s*)|(\d+$), reading, Spaces at the start, or digits at the end.