# Contains function

**URL:** <https://forum.uipath.com/t/contains-function/703870>\
**Category:** Studio\
**Tags:** contains, question, studio, activities\
**Created:** [3. Dezember 2023 um 22:33 UTC](https://forum.uipath.com/t/contains-function/703870 "2023-12-03T22:33:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arya\_Squares](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/arya_squares/32/323585_2.png) [@Arya\_Squares](https://forum.uipath.com/u/Arya_Squares)\
**Post date:** [3. Dezember 2023 um 22:33 UTC](https://forum.uipath.com/t/contains-function/703870/1 "2023-12-03T22:33:47Z")

</div>

Hi everything,  
Can anyone help me on this

Str1 = "system.exception unable to find a click sleelector.

Type into click aqaes test knfkajfkaguwbdiwndkdb  
Wnajjskdjfjdjdjjwwhn wiwnd exception edjf fmjsnhjwnwh"

Str2 ="System.exception unable to find a click sleelector.

Type into click aqaes test knfkajfkaguwbdiwndkdb  
Wnajjskdjfjdjdjjwwhn wiwnd exception edjf fmjsnhjwnwh"

When I’m using if condition like

Str1.trim().contains(str2).trim()

Above 2 string as same letters space everything but still it is falling in false.

---

<div class="post-metadata">

**Author:** ![rikulsilva](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rikulsilva/32/462189_2.png) [@rikulsilva](https://forum.uipath.com/u/rikulsilva)\
**Post date:** [3. Dezember 2023 um 22:44 UTC](https://forum.uipath.com/t/contains-function/703870/2 "2023-12-03T22:44:50Z")

</div>

> [@Arya\_Squares](#):
>
> System.exception unable to find a click sleelector.
> 
> Type into click aqaes test knfkajfkaguwbdiwndkdb  
> Wnajjskdjfjdjdjjwwhn wiwnd exception edjf fmjsnhjwnwh

Hi @Arya_Squares

You can use this site to compare text

[Text Compare! - Find differences between two text files (text-compare.com)](https://text-compare.com/)

in your case, contains method is case sentitive You can check using this:

```auto
Str1.ToLower().Trim().contains(Str1.ToLower().Trim())

```

it will convert the strings to lowercase before compare

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [3. Dezember 2023 um 23:42 UTC](https://forum.uipath.com/t/contains-function/703870/3 "2023-12-03T23:42:24Z")

</div>

Hi,

There might be difference regarding white space.  
Can you try the following expression?

```
System.Text.RegularExpressions.Regex.Replace(str1,"\s+"," ").Contains(System.Text.RegularExpressions.Regex.Replace(str2,"\s+"," "))

```

Regards,

---

<div class="post-metadata">

**Author:** ![harrywilliam6543](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@harrywilliam6543](https://forum.uipath.com/u/harrywilliam6543)\
**Post date:** [5. Dezember 2023 um 06:21 UTC](https://forum.uipath.com/t/contains-function/703870/4 "2023-12-05T06:21:48Z")

</div>

It seems the issue might be with white spaces. Try this expression for a more robust check:  
System.Text.RegularExpressions.Regex.Replace(Str1, @“\s+”, " “).Contains(System.Text.RegularExpressions.Regex.Replace(Str2, @”\s+", " "))

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [8. Dezember 2023 um 06:22 UTC](https://forum.uipath.com/t/contains-function/703870/5 "2023-12-08T06:22:21Z")

</div>

Geschlossen, am 8. Dezember 2023 um 06:22 UTC

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