我的正则表达式必须解析多行字符串中超过6个符号的所有单词。
Pattern pattern = Pattern.compile("(\\w{7,}\\s\\b.*)");
Matcher mm = pattern.matcher(lines);
if (mm.matches()) {
String oldGroup = mm.group();
________以下是示例输入:
1234567 1234567 1234567
1234 123 1234567
123 12345 1234 1234567
123
_______这是预期的输出:
1234567 1234567 1234567 1234567 1234567
所以,我只需要输出带有6个或更多字母符号的单词。
答案 0 :(得分:0)
(\b\S{7,}\b)/
1st Capturing group (\b\S{7,}\b)
\b assert position at a word boundary (^\w|\w$|\W\w|\w\W)
\S{7,} match any non-white space character [^\r\n\t\f ]
Quantifier: {7,} Between 7 and unlimited times, as many times as possible, giving back as needed [greedy]
\b assert position at a word boundary (^\w|\w$|\W\w|\w\W)