I am working in c# and i am trying to check a string for a value {some value}. Most importantly i am looking for whether the string contains {}, with something in between. I was thinking reg-ex but i don't really know how to implement that within a String.Contains. I have tried creating a reg-ex instance and passing that into the Contains but that doesnt seem to work. Please let me know if there is an easier approach.
if (uri.Contains("{one word}"))
{
}
return false;
This is what ive tried,
public bool SimpleResponseCodeCheck(string callTested, string testName)
{
testParams = SupportingMethodsClass.ReturnXMLData(callTested, testName);
string uri;
string method;
string requestBody;
string expResponseCode;
string actResponseCode;
string statusMessage;
string respBody;
Regex testParameter = new Regex("\\{.+\\}");
testParams.TryGetValue("uri", out uri);
testParams.TryGetValue("method", out method);
testParams.TryGetValue("expResponseCode", out expResponseCode);
testParams.TryGetValue("requestBody", out requestBody);
if (testParameter.IsMatch(uri, 0))
{
}
return false;
}
Contains? Do you not have access to the documentation?Regexclass.Contains, and that a glance at the documentation for that method would have shown that it has no regular expression functionality.