假设我有以下文本文件(称为test.txt
):
\centerline{\includegraphics[width=0.50 \columnwidth]{example_graph.pdf}}
\centerline{\includegraphics[width=0.5 \columnwidth]{coarse_grain_illustration.png}}
\centerline{\includegraphics[width= 0.8 \columnwidth]{1y26_energy_dists.pdf}}
如果我用贪婪匹配进行搜索,则会得到预期的结果:
[user@host test]$ grep '\\includegraphics.*df' test.txt
\centerline{\includegraphics[width=0.50 \columnwidth]{example_graph.pdf}}
\centerline{\includegraphics[width= 0.8 \columnwidth]{1y26_energy_dists.pdf}}
===========================================================================================================
但是,如果我使用惰性评估,则不会得到任何结果:
[user@host test]$ grep '\\includegraphics.*?df' test.txt
===========================================================================================================
是什么赋予了?为什么使用惰性评估不匹配本质上相同的模式?
.*?
或并非到处都支持惰性模式。您将必须grep -P
在perl模式下使用或grep来实现它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句