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.

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.

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?

That works on my end
This regex matches only if
user_answer
is specifically: "callback"So "Callback" won't work? How do I make it case insensitive?
/^callback$/i
Hmmm
Like this?

Doesn't work for me still.
Here is a simple working typebot: https://app.typebot.io/typebots/cluqn0gux000q113pb6zqoam2/edit
It works when typing
callback
or Callback
Feel free to share your example to help me understand what's going on 🙂