T
Typebot•8mo ago
Erisch

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
LuizAlves
LuizAlves•8mo ago
Maybe converting to uppercase or lowercase before to compare
Erisch
Erisch•8mo ago
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.
Baptiste
Baptiste•7mo ago
The regex should work! Can you provide a reproduction?
Erisch
Erisch•7mo ago
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
Erisch
Erisch•7mo ago
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...
drippingfist
drippingfist•6mo ago
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?
Baptiste
Baptiste•6mo ago
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 🙂
drippingfist
drippingfist•6mo ago
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
Baptiste
Baptiste•6mo ago
Indeed, I reproduced. Fixing it asap
Erisch
Erisch•6mo ago
Exactly. It converts to lowercase first.
Mark's
Mark's•6mo ago
ok
Baptiste
Baptiste•6mo ago
Should be fixed in 10 min
drippingfist
drippingfist•6mo ago
I saw it's resolved but I can't get it to work still. Should it be like this?
No description
Want results from more Discord servers?
Add your server