如何捕获多个文本块

时间:2015-10-08 06:58:06

标签: c# regex

我有一个文本文件,文件内容为

CGSize kbSize = [[[sender userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
NSTimeInterval duration = [[[sender userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];

CGFloat height = UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation]) ? kbSize.width : kbSize.height;

[UIView animateWithDuration:duration animations:^{
UIEdgeInsets edgeInsets = _generalTableView.contentInset;
edgeInsets.bottom += height;
_generalTableView.contentInset = edgeInsets;
edgeInsets = _generalTableView.scrollIndicatorInsets;
edgeInsets.bottom += height;
_generalTableView.scrollIndicatorInsets = edgeInsets;
}];

我希望使用c#通过正则表达式返回文本块的数组,数组结果有三个项目:

  

开始= 0001-测试-1
  端= 0001-测试-1

     

开始= 0002-测试-2
  端= 0002-测试-2

     

开始= 0003-测试-3
  端= 0003-测试-3

正则表达式如何为这种情况写作?

2 个答案:

答案 0 :(得分:0)

这将为您提供匹配(您需要使用多行标记):

^Begin(.|\n)*?End.*$

请参阅sample

答案 1 :(得分:0)

\bBegin[\s\S]*?\bEnd\b.*

你可以简单地使用它。参见演示。

https://regex101.com/r/cJ6zQ3/36