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.
rikulsilva
(Henrique Lima da Silva)
December 3, 2023, 10:44pm
2
Hi @Arya_Squares
You can use this site to compare text
Text Compare! - Find differences between two text files (text-compare.com)
in your case, contains method is case sentitive You can check using this:
Str1.ToLower().Trim().contains(Str1.ToLower().Trim())
it will convert the strings to lowercase before compare
Yoichi
(Yoichi)
December 3, 2023, 11:42pm
3
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,
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+", " "))