How to match the word only with the whole words(String) in uipath?

when trying to match a word in the string, only whole words need to be checked (For Ex: when “MALE” word is searched and it should search for only “MALE”, it shouldn’t match in the word “FEMALE” which also contains MALE in it). Without using Regex.

Hey! Welcome to community!

We can do like this

Variable.Equals("MALE")

Use this in if condition

Then block you will get the MALE
Else block you will get the FEMALE

Regards,
NaNi

(string.contains(“male”)) and not string.contains(“female”)

use this condition

if I searched for the MA word with a string, it can be found in many words like match, mammoth, sumanth etc can’t be done like you said. That can’t be generalized.

i using “.contains” to match the word with the string, variable.equals() can’t be used while matching.

Hey!

If you are using the contains the FEMALE and MALE. Both the strings will come…

If you use equals whenever the match found this will returns the true value…

Contains: Checks the match in the entire string if found returns the true

Example: 1

Input: All ARE FEMALE

Expression: Input.Contains("MALE")

Result: TRUE

Reason: In the above input string contains the MALE.

Example: 2

Input: FEMALE

Expression: Input.Equals("MALE")

Result: False

Reason: The above string not matching with the searched value.

Equals: Equals match with the entire string

Example: 1

Input: MALE

Expression: Input.Equals("MALE")

Result: TRUE

Reason: The string matching with the searched string.

Example: 2

Input: All ARE FEMALE

Expression: Input.Equals("MALE")

Result: FALSE

Reason: Not matching with the searched string

Regards,
NaNi

Hello @Umaprashanth_J

Are you trying to check for some predefined strings? If yes, it would be better to use “IsMatches” activity. You can provide the regular expressions to match only the exact word. If you are using contains, then you will have to use if conditions to verfiy it again.

Thanks