cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 

Expression to limit answers on a question

I have a single line question that uses  Real Number as the format input and would like to change it using an expression so a user can only input the number 1 or the number 2.

I haven't found an expression that works and wondering if anyone has done this

(1) Solution

If you only have a finite list of possible answers, why use a single line text entry instead of a drop-down list or radio buttons?  Try adding a new expression under Catalog Management > Expressions, and use the expression ^[12]$.  This should only match if a 1 or a 2 is entered with no other characters.  For what it's worth, regex101.com is a great resource if you need help with regular expressions.

Anything expressed here is my own view and not necessarily that of my employer, Flexera. If my reply answers a question you have raised, please click "ACCEPT AS SOLUTION".

View solution in original post

(4) Replies

If you only have a finite list of possible answers, why use a single line text entry instead of a drop-down list or radio buttons?  Try adding a new expression under Catalog Management > Expressions, and use the expression ^[12]$.  This should only match if a 1 or a 2 is entered with no other characters.  For what it's worth, regex101.com is a great resource if you need help with regular expressions.

Anything expressed here is my own view and not necessarily that of my employer, Flexera. If my reply answers a question you have raised, please click "ACCEPT AS SOLUTION".

Should have known that Jim would come up with a better and quicker answer than I šŸ˜Š I was going to suggest ^(?:[1-2])$

I never was very good at regular expressions!

Don't feel bad, Charlie.  I've never been good at regular expressions either, which is exactly why I keep that website bookmarked!  šŸ˜€

Anything expressed here is my own view and not necessarily that of my employer, Flexera. If my reply answers a question you have raised, please click "ACCEPT AS SOLUTION".

Thanks Jim!  I'm bookmarking this site for future.