regex: force entire string to match
Justin Whear
justin at economicmodeling.com
Tue Jan 31 09:05:42 PST 2012
On Tue, 31 Jan 2012 16:29:43 +0000, NewName wrote:
> Hello all.
> 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?
>
> Thank you for reading.
You want to match the beginning and end of the input as well:
"^[0-9]+$"
More information about the Digitalmars-d-learn
mailing list