Could you help me constraint a phone number to both 9 and 10 digits phone numbers with regex?

Hi @Kal_Lam

We do have phone numbers of both 9 and 10 digits here. for now i’ve used this regex(.,‘^[0-9]{10}$’) which only allows me to enter 10 digits. could you please help me putting constraints to both 9 and 10 digits phone numbers in a single regex.

Hi @Hems and welcome to the community!

regex(.,‘^[0-9]{9,10}$’)

Should work for you.

1 Like

@hakan_cetinkaya Thank you it worked!

2 Likes

Welcome @Hems,
You may always use the search function of this forum to find help, e.g. your topic has been discussed here about 20 times: Search results for 'phone number regex' - KoboToolbox Community Forum
Also, often the Help Centre articles provide support, e.g. https://support.kobotoolbox.org/restrict_responses.html?highlight=examples and
https://support.kobotoolbox.org/number_text_responses.html?highlight=phone%20number.

1 Like