我在c#工作,我正在尝试检查字符串的值{some value}
.最重要的是,我正在寻找字符串是否包含{},其中介于两者之间.我在想reg-ex,但我真的不知道如何在String.Contains中实现它.我已经尝试创建一个reg-ex实例并将其传递给Contains但这似乎不起作用.如果有更简单的方法,请告诉我.
if (uri.Contains("{one word}")) { } return false;
这是我尝试过的,
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; }
SLaks.. 5
你正在寻找这个Regex.IsMatch()
功能,它正是这样做的.
你正在寻找这个Regex.IsMatch()
功能,它正是这样做的.