Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 正则表达式模式,用于获取两个单词之间的所有行文本_Regex - Fatal编程技术网

Regex 正则表达式模式,用于获取两个单词之间的所有行文本

Regex 正则表达式模式,用于获取两个单词之间的所有行文本,regex,Regex,我想创建一个正则表达式模式来获取两个单词之间的内容 Start: Apple Cat Ball End: 我想获取开始:和结束之间的数据: 我可以用C#找到这些数据: 区域获取所需的字段数据 公共静态列表GetRequiredData(字符串[]行、字符串StartPos、字符串EndPos) { List RequiredField=新列表(); bool-hit=false; foreach(行中的var行) { 如果(行==结束位置) { 命中=错误; } else if(hit==tr

我想创建一个正则表达式模式来获取两个单词之间的内容

Start:
Apple
Cat
Ball
End:
我想获取开始:和结束之间的数据:

我可以用C#找到这些数据:

区域获取所需的字段数据
公共静态列表GetRequiredData(字符串[]行、字符串StartPos、字符串EndPos)
{
List RequiredField=新列表();
bool-hit=false;
foreach(行中的var行)
{
如果(行==结束位置)
{
命中=错误;
}
else if(hit==true)
{
如果(行!=“\t”|行==”)
{
必填字段。添加(行);
}
}
else if(行==StartPos)
{
命中=真;
}
}
返回所需字段;
}
#endregion获取所需的字段数据
但我认为使用正则表达式达到同样的目的会很酷。
我试过(?我不是正则表达式专家,但我试过了:

beginningword\n((.+\n)+)endingword
对于文本:

beginningword
first line of whatever
second line of whatever
third line of whatever
endingword
与组#1匹配的文本为:


我不是正则表达式专家,但我尝试过:

beginningword\n((.+\n)+)endingword
对于文本:

beginningword
first line of whatever
second line of whatever
third line of whatever
endingword
与组#1匹配的文本为:


我试过上面的模式,但不起作用。(?s)(我想用regex是不可能的。没问题,我确实用我的代码删除了空格。但我仍然认为用regex是可能的,不知道怎么做。…我开始学习它。我试过上面的模式,但不起作用。(?s)(?我认为使用regex是不可能的。没问题,我确实用我的代码删除了空格。但我仍然认为使用regex是可能的,不确定如何…我开始学习它。您确实可以尝试RegExp:您确实可以尝试RegExp: