I have something like:
string result = Selenium.GetText("/html/body/form/div[2]");
if (result.Contains("test")
{
bool found = true;
}
else
{
found = false;
}
My problem is using result.Contains()
returns false if there are tests, testing, etc. Also returns false for uppercase TEST, Test, etc
Is there another method that would match each character? Something like: result.Match("test");
Thanks for helping me out.
string.StartsWith
is a good start, and then Regex
if you need more power
Pardon my awful code, though it works:
var aStartsWithB = stringA.ToUpper().StartsWith(stringB.ToUpper());
var aContainsB = stringA.ToUpper().Contains(stringB.ToUpper());
contains it should work fine:
public static void Main()
{
string result = @"/html/body/form/tests123456";
var containsTest= result.Contains("test"); // <--True
}
Just bear in mind that Contains is case sensitive
You could use a version of string.Contains case insensitive as showed on thepost below.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.