cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
TeriStevenson
Level 7

Expression to limit answers on a question

Jump to solution

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

0 Kudos
1 Solution
jdempsey
Moderator Moderator
Moderator

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
jdempsey
Moderator Moderator
Moderator

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".
CharlesW
Level 11 Flexeran
Level 11 Flexeran

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".
0 Kudos

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

0 Kudos