【发布时间】:2019-10-24 20:39:35
【问题描述】:
我正在尝试使用 C# 使用已知模式解析文本。我有以下文字
Fn.StartIf(some condition)
Block of blob text. This text could start with a new line or it may not... This text could be anything including numbers and special characters number like 123.
and it multiple lines of text and could end with a new line or not.
Fn.EndIf
最后,我想得到以下组:
- (第 1 组)Fn.StartIf(某些条件)
- (第 2 组)某些情况
- (第 3 组)中间的所有文本
- (第 4 组)Fn.EndIf
这是我尝试过的(Fn.StartIf\((.+)\))^(.+|\n*|\s*)$(Fn.EndIf)。但是,^(.+|\n*|\s*)$ 模式并没有抓取 Fn.StartIf(some condition) 之后和 Fn.EndIf 之前的所有 blob 文本
如何正确抓取Fn.StartIf(some condition) 和Fn.EndIf 之前的所有blob 文本?
【问题讨论】: