Uppercase regex code

Hello @Kal_Lam Thank you for the information you provided. I want to make only capital letters starting A-Z with punctuation marks and numbers for the address question. I will be glad if you help. ie.(ANKARA-TURKEY 20/4)

Is there any limitations with the length of ANKARA and TURKEY or are they a fixed words that each enumerators has to use. Besides, what does 20/4 signify? Is it just a 2 digit/1digit format?

There is no limitation for the length. Actually it can be any address format.The thing is comprises only capital letters and may include numbers or punctuations. @Kal_Lam

Maybe you could try it as outlined in the image shared below:

In the survey tab of your xlsform:

Data entry screen as seen in Enketo: wrong entry is made

Data entry screen as seen in Enketo: correct entry is made

Reference xlsform:

UPPER CASE (Regex).xlsx (10.1 KB)


Hello again @Kal_Lam yes its working properly. thank you for your support it is really much appreciated.


One last thing @Kal_Lam , when I use Turkish characters, the capitalization rule does not work. For example, when I write β€œΓΌβ€ β€œΔŸβ€ β€œΓ§β€, it accepts them as lowercase.is there a way to prevent this. Thanks

I am not aware with the Turkish script but one check, have you changed your input mode to Turkish language? Maybe this should help you solve your issue. Kindly please let us know what happens. This should help the community!

1 Like

Input mode is in Turkish language but problem still continues. @Kal_Lam

1 Like

Maybe some colleagues having knowledge with Turkish should be able to help us solve this issue.

I would be more than happy if you can inform me after find solution. @Kal_Lam

You may try to just add all these special Turkish characters to the list in the [ …]
Attention; The regex example will allow any combination and order, like " " or β€œ+ ? -” or β€œ-1 A”.

You can use the search function of this forum to get more examples and discussion, with the toke β€œuppercase”.

Maybe also the translate function (as calculation) might be interesting, to automatically correct the input. https://www.w3.org/TR/1999/REC-xpath-19991116/#function-translate
Enter Text to be in Uppercase

Maybe @Xiphware knows, if character classes [:alpha:] OR those classes for Unicode, like \p{Uppercase_Letter} can be used with KoBo/ODK regex. Or [:alpha:]
(See https://en.wikipedia.org/w/index.php?title=Regular_expression&action=view&section=19#Character_classes and

Kind regards

1 Like

Hello thanks for your answers. I added all the Turkish charachters to the list but it still accepts lower case for only Turkish charachters. Please see my constrait formula below.

regex(.,’^[A-ZΓ‡Γ–Δ°ΕžΔžΓœ 0-9\W]+$’)

You may try to remove the \W, so only Uppercase, Blank and 0-9 will be allowed.

Hello @wroos when I delete β€œ\ W” this expression it works(doesn’t accept lower letters Turkish characters too.) but then it does not accept punctuation marks too , I want only capital letters and may include numbers or punctuations.

Would you mind to have a look for better understanding of regex features here, please:

You can add all allowed characters in the […] list. (But each of them is valid to be entered as first character.)

1 Like