Community Health Toolkit

What is the best way to match a word without case sensitivity in the webapp configurations?

Imported Question by samuel · Mar 21, 2017 at 11:57 AM

If you have a given set of words or codes (usually for text forms), what is the most efficient regex to use in the web-app validation such that the user can input the word or code in any case (upper, lower, or mixed)? I have tried /^(word1|word2)$/i but this doesn’t seem to work.

“Validation setings may consist of Pupil.js rules and custom rules” (from sentinel)

From trying it out it looks like Pupil doesn’t allow flags for regexes (like the /i flag, which you are rightly trying to use).

But there is an iEquals function in Pupil, for case-insensitive comparison.

And you can use || for logical OR

So you can do this rule: 'iEquals("mary") || iEquals("john")'

Matches “mary”, “Mary”, “john”, “John”, “JOhN”, etc. Not “maryjohn”.

2 Likes