If you really need to reuse the String obtained from Matcher.group, it is better to create a new line, since what you get from Matcher.group is actually a substring whose link points to the original one. Thus, when you read the link a second time and go to Pattern.matcher (), you are not actually passing the exact string that you get from the first step. Perhaps this is a mistake or it is designed to work in this way. But for your situation, create a new line every time Matcher.group () always makes life easier. I hope I have explained this correctly and completely.
String[] regexContent = {"node[\\s\\S]*?(<p>[\\s\\S]+</p>)", "([\\s\\S]*?)</div>"}; Pattern p; Matcher m; for (String regex : regexContent){ p = Pattern.compile(regex); m = p.matcher(result); //if (m.matches()) // always false result = ""; if (m.find()) // on 2nd step waits for so long time & don't find result = new String(m.group(m.groupCount())); m.reset(); }
Felix Sep 04 '13 at 4:55 on 2013-09-04 04:55
source share