How can i check a variable without case sensitivity?
Right now I use a condition element:
variable Contains string
OR
variable Contains String
How can I make this more elegant?
I tried to use regex /^string$/i but this does not seem to work.
22 Replies
Maybe converting to uppercase or lowercase before to compare
I'll try that. It would require to work with the script module. Which is kind of hard for someone like me. But I'll give it a shot. Thanks.
The regex should work!
Can you provide a reproduction?
I tried to do it like this. But it did not work. I managed to write a javascript though with a different approach that works fine.
![No description](https://cdn.answeroverflow.com/1211306838738599947/Screenshot_2024-02-25_at_14.40.01.png)
var checkExit = {{user-message-openai}}.toLowerCase();
if(['exit', 'quit', 'menu', 'home', 'back', 'ragequit'].includes(checkExit)) {
setVariable('user-message-openai', 'exit')
}
This script checks regardless of capital or lowercase letters if someone entered Exit, exit EXIT...
Maches regex doesn't work for me.
Hi Erisch. Sorry for being slow here, but does your script convert the user-message to lower case and then if it's exit, quit, menu, home, back, or rage quit it changes it to exit?
If you have a use case that does not work, provide a reproduction so that I can check if there is a bug on Typebot's side 🙂
regex documentation doesn't mention case sensitivity. But also it doesn't seem to work. In this case typing callback does nothing, human works.
![No description](https://cdn.answeroverflow.com/1222347246704787456/image.png)
Indeed, I reproduced.
Fixing it asap
Exactly. It converts to lowercase first.
ok
Should be fixed in 10 min
I saw it's resolved but I can't get it to work still. Should it be like this?
![No description](https://cdn.answeroverflow.com/1224223634554355793/image.png)