How to assign a boolean value for a string if it contains specific texts

Hi, I would like to know how can I assign a boolean value to a string that contains specific texts?

Specifically, I want it to be like this:
when the string contains “Yes” return a boolean value of True
when the string contains “No” return a boolean value of False.

Sorry if this sound too easy I am quite new to UiPath automation, I just hope to get some assistance on this

Hi @Ben_siu

  1. Use If condition
"YourString".Contains("Yes")

image

If the String is Yes it will Go to Then part

If the String is No it will Go to Else part

Regards
Gokul

1 Like

Hello,
if you want to have it concise, you can use inline if in Assign activity. If YourString will be “Yes”, then it will assign True to YourBool, if YourString will be anything else, it will assign False.

image

1 Like

@Ben_siu
Please use assign activity
on left side put bool variable
right side put string operation like this

2 Likes

Hello @Ben_siu , Try this
YourString=“The Answer is Yes”

YourString.Contains("Yes")

it will return as “True”, If there is no "Yes in your string, it will returns “False”

1 Like

Hello,

Try inline if condition like below-

if(mystring.contains(“Yes”), “TRUE”, if(mystring.contains(“No”),“FALSE”,‘’ "))

Regards,
Kalyan

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.