简体   繁体   English

如何使用C#比较动态字符串

[英]How to compare dynamic strings using C#

I have a following string format 我有以下字符串格式

Cover: 覆盖:

Category 1(1 is dynamic) - Type - Google(Google is dynamic), some dynamic strings 类别1(1是动态的)-类型-Google(Google是动态的),一些动态字符串

I want to confirm that whether Category, Type and some dynamic strings following are present under Cover header using C# 我想确认使用C#在Cover标头下是否存在Category,Type和以下一些动态字符串

What could be the best approach to achieve this scenario? 什么是实现此方案的最佳方法?

if u wana IgnoreCase 如果你想忽略案例

if(Regex.IsMatch(myString, Regex.Escape("Category"), RegexOptions.IgnoreCase) && .....){}

else use 否则使用

if( myString.Contains("Category") &&.....) { }

if have a list of words u can use a loop let me know i will edit ans according to that 如果有单词列表,您可以使用循环让我知道我将根据该内容来编辑ans

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM