How to add apostrophe in the regex?

Greetings all,

I am trying to add apostrophe in the regex . But I am getting an error as "Error: ODK Validate Errors:
org.javarosa.xform.parse.XFormParseException: bind for ${name_of_he} contains invalid constraint expression [string-length(.)<=150 and regex(., '[A-Za-z ().',%+-]{1,150}')] Couldn't understand the expression starting at this point: ...'[A-Za-z ().',?%+-]{1,150}')" . . I have searched the forum for the answer but was unable to find one . I got one old link where i some one asked a similar question!topic/opendatakit/eYrEDivmybo .

Thanks and Regards,

This seemed to work for me:

| type | name |  label  |                          constraint                           |
| text | name | Answer? | string-length(.)<=150 and regex(., "[A-Za-z ().',%±]{1,150}") |

The single quote inside of your wrapping single quotes might have been causing a problem.

Let me know if this helps.


The validation seems to run into trouble at the first single quote. I think the issue may be that that single quote is curved (also called "curly" or "smart"), when the parser expects it to be straight/vertical.

Hello danbjoseph,

Sorry for the late reply . Ya it worked . I am not getting that error any more. Thank you for the suggestion.

Thanks and Regards ,