【发布时间】:2011-10-26 10:07:59
【问题描述】:
我有一个这样的 .txt 文件:
[abc]
There is
a lot of
contents here
[abc]
[def]
Here are
many other
contents
[def]
[ghi]
and bunch of
contents here too
[ghi]
我想打印出标记字符串之间的内容,例如:打印出[abc]和[abc]之间的所有内容,而不打印出任何[abc]行。我怎么能做到这一点?
【问题讨论】:
-
如果所有标记行都以
[开头,并且没有其他内容行以[开头,则过滤所有以[开头的行。正则表达式应该是这样的^[.*$多行模式 -
你达到你想要的了吗?
标签: java string file-io java.util.scanner