A known deficiency with the current version of Survey123 Connect is that it does not evaluate constraints until form submission. Many users have the need or desire to have their surveys evaluate a regular expression constraint before proceeding to the next question or next page in their form (more on the problem here).
Below is a possible (although somewhat clunky) work-around. It uses 'note' type rows so that no new fields are required in the data schema.
- Identify the data field row that you want to validate with regex and insert two new rows below it.
- Set both new row types to 'note'.
- For the first note, make its 'appearance' hidden and write an 'if' expression in the 'calculation' column that evaluates your regex expression, returning some simple Boolean-like values like OK/bad, True/False, Yes/No, etc. Example: if(regex(${field2check}, '^[a-zA-Z]'), "OK", "bad")
- For the second note row, leave its 'appearance' visible, but set its 'relevant' column to ${field2check}!="" and ${calc_row}!="OK" (this means that this note will not be visible unless the field that you're trying to validate is not blank and it has been evaluated as not "OK" by the calculation done in the row above. Set the text ('label') for this row to whatever you want your error message to be.
Here is a simplified example:

| type | name | label | appearance | required | required_message | calculation | constraint | constraint_message::default | constraint_message | relevant |
| begin group | user_info | User Info | field-list | | | | | | | |
| text | name | Name | | yes | Enter a valid name to proceed | | | | | |
| note | namecheck | namecheck | hidden | | | if(regex(${name}, '^[a-zA-Z]'), "OK", "") | | | | |
| note | nameerrornote | Enter a valid name to proceed | | | | | | | | ${name}!="" and ${namecheck}!="OK" |
| range | age | Age | | yes | | | | | | ${namecheck}="OK" |
| text | additionalnotes | Additional Notes | | | | | | | | ${age}!="" |
| end group | | | | | | | | | | |
There may be more elegant workarounds, so if you're aware of ways to make this more slick, please comment.