我需要使用sed
命令正则表达式查找文本文件中的第一个空行。
下面是我所拥有的内容
this is defile
to be cleaned
skip rest consl
在上面的内容中,我只需要找到第一行是空行,然后删除第一行。
我使用了下面的正则表达式,但它对我不起作用,它发现文件中到处都是空行。
^\s*$
发布于 2019-03-22 11:53:24
在Java中,您可以这样做:
Pattern pattern = Pattern.compile ("^\\s*$", Pattern.MULTILINE);
Matcher matcher = pattern.matcher ("foo\n \nbar");
if (matcher.find()) {
String firstEmptyLine = matcher.group();
...
}
https://stackoverflow.com/questions/55298934
复制相似问题