我有很多格式如下的文件:
SIMPLE
{
residualControl
{
p 1e-4;
U 1e-4;
"(k|omega|epsilon)" 1e-4;
}
nNonOrthogonalCorrectors 0;
pRefCell 0;
pRefValue 0;
}
potentialFlow
{
nNonOrthogonalCorrectors 10;
}
relaxationFactors
{
fields
{
p 0.3;
}
equations
{
U 0.7;
"(k|omega|epsilon).*" 0.7;
}
}
我想在文件夹中的所有文件中匹配以下文本块$FOAM_TUTORIALS/incompressible
:
residualControl
{
// line 1
// line 2
// ...etc
}
当我使用pcregrep
如下:
pcregrep --color -r -M "residualControl.*\n.*\{(.*\n)*" $FOAM_TUTORIALS/incompressible/
它也与其他行匹配(请参阅下面的评论):
SIMPLE
{
residualControl
{
p 1e-4;
U 1e-4;
"(k|omega|epsilon)" 1e-4;
} // <<<<<<<<<<<<<<<<<<<<<<<<<<< I want it to stop match here. But it matches also the lines below
nNonOrthogonalCorrectors 0;
pRefCell 0;
pRefValue 0;
}
potentialFlow
{
nNonOrthogonalCorrectors 10;
}
relaxationFactors
{
fields
{
p 0.3;
}
equations
{
U 0.7;
"(k|omega|epsilon).*" 0.7;
}
}
您能否告诉我如何修改正则表达式以仅匹配第一个块?