We help IT Professionals succeed at work.

Regular Expression - numeric only (Either a zero or 10 digit number)

mauricerichard
on
Hello Experts,

I need a regular expression that will force the user to enter ether:

1) a zero
2) a ten digit number

So this needs to be numeric only, no spaces, dashes, ect.

Thanks!
Moe
Comment
Watch Question

BRONZE EXPERT
Commented:
^0|\d{10}$

Author

Commented:
Perfect, thank you for the solution!!
BRONZE EXPERT

Commented:
Glad to help :)
ozo
SILVER EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
I think you meant
^(0|\d{10})$

otherwise $ would not be required after 0 and ^ would not be required before \d{10}

Explore More ContentExplore courses, solutions, and other research materials related to this topic.