我有一个这样的模式
"The world is #bright# and #beautiful#"
我需要在 # # .. 任何指针中检索字符串 "bright","beautiful"
我的解决方案(感谢 Bolu):
string s = "The world is #bright# and #beautiful#";
string[] str = s.Split('#');
for (int i = 0; i <= str.Length - 1; i++)
{
if (i % 2 != 0)
{
Response.Write(str[i] + "<br />");
}
}
最佳答案
如果你想要的只是##中的字符串,那么不需要正则表达式,只需使用string.Split:
string rawstring="The world is #bright# and beautiful";
string[] tem=rawstring.Split('#');
之后,您只需从 string[] tem
中获取偶数项(索引:1,3,5....)
关于c# - 检索特定模式内的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3736133/