正则表达式允许多个和单个字符

时间:2015-03-05 18:24:01

标签: regex

@**** temp between 100.75 - 115.00 ---Important notice. Good bye..,,... --- **** //\\  

我需要一个正则表达式来返回

temp between 100.75 - 115.00 Important notice. Good bye.

允许的字符:字母(上部和下部),单个,单个,单个, 数字,单个空格,单身?

1 个答案:

答案 0 :(得分:0)

(?<=@\*{4}\s).*?(?=\.{2},{2})

如果支持lookaheads,那么您可以尝试这种方式。参见演示。

https://regex101.com/r/eS7gD7/21

string strRegex = @"(?<=@\*{4}\s).*?(?=[.,]{2,})";
Regex myRegex = new Regex(strRegex, RegexOptions.Multiline);
string strTargetString = @"@**** temp between 100.75 - 115.00 ---Important notice. Good bye..,,... --- **** //\\";

foreach (Match myMatch in myRegex.Matches(strTargetString))
{
  if (myMatch.Success)
  {
    // Add your code here
  }
}