Hi,
I'm having an issue implementing a constraint to a text field in a survey I'm designing. The string input can be any length, but it can only consist of the characters 0, 1, and 2. Any other character should throw a flag. What I've currently implemented is:
regex(.,'^[0-2]*$') |
This tends to work -- however, it only works for the first two characters in the string. If the string is any longer than two characters, it throws the constraint flag (strangely, the error message appears like this, instead of tied to the question, as it usually does/should) :
I have no experience writing regex, so any help would be useful. Thank you!
Hello @GrantZ,
Using regex(.,'[0-2][0-2][0-2]') would be one way to reach the regex you are looking for.
Thanks @ZacharySutherby. Is there a way to adapt this to account for a string of any length? The string that a user will enter could be any length.
@GrantZ, is the field type for the entry you're using the regex on a text/string field? If so, Survey123 will give it a length of 255 characters by default in the hosted feature services it creates when the S123 form is published to ArcGIS Online, so I think you could adjust the regex to match this character length.