Hi All,
I am trying to fix my beneficiary name with regex. I need to collect some names. These names can be one word name, two word name, or even three, four or five words name. Number of words in a name is not pre defined. I want first letter of all names to be capital letter.
For example:
- Ayatullah
- Athaul Karim
- Saifullah Mohammad Faisal
- Mohammad Tasfik Uddin Rukan
For this, I have input regex in constraint like this:
regex(., ‘^([A-Z]{1}[a-z]{1,}\s)([A-Z]{1}[a-z]{1,}\s?)+$’)
It works fine. The only problem is, it does not allow one word name. How can I fix this? Any suggestion? Thanks in advance.
@tasfik_rukan, you could do it as shown in the image shared below using the regex code regex(., '^([A-Z]{1}[a-z]{1,}\s?)+$')
:
In the survey tab of your xlsform:

Data entry screen as seen in Enketo: when a wrong entry is made
Data entry screen as seen in Enketo: when a correct entry is made
Data entry screen as seen in Enketo: when a correct entry is made
Data entry screen as seen in Enketo: when a wrong entry is made
Data entry screen as seen in Enketo: when a correct entry is made
Reference xlsform:
Regex_Constraint.xlsx (9.9 KB)
1 Like
Hi Kal_Lam, Thanks a lot for your kind reply. My problem is solved.
2 Likes