我想顯示文本中的所有行,但目前我只顯示第二行。該錯誤是在我rowRegex :( 我將是任何幫助,非常感謝選擇文本中的所有圖案
我的代碼:。
package test.jpa;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FireTest {
public static void main(String[] arStrings) throws Exception {
String str = "*PureNG*#"
+ "\"*Part*\":https://pure1.pdf** \"Part1\":https://pure2.pdf** \"Part2\":https://pure3.pdf** \"Part3\":https://pure4.pdf#"
+ "\"*Fakt*\":https://pure5.pdf** \"Fakt1\":https://pure5.pdf** \"Fakt2\":https://pure6.pdf#"
+ " \"*WZ* _(wydanie)_\":https://pure7.pdf#"
+ " \"*ZA*\":https://pure8.pdf** \"PA\":https://pure9.pdf#"
+ " \"*Close*\":https://pure11.pdf** \"Close1\":https://pure12.pdf#"
+ " \"*Stany*\":https://pure13.pdf</text><version>7</version><author id=\"1\" name=\"UserName LastName Admin\"/><comments></comments> <created_on>2015-11-26T15:08:26Z</created_on><updated_on>2015-11-30T15:44:00Z</updated_on></wiki_page>";
String rowRegex = "(#.*?#|\\Z)";
Pattern patternRow = Pattern.compile(rowRegex);
Matcher matcher = patternRow.matcher(str);
while(matcher.find()) {
System.out.println("Finded: " + matcher.group());
}
}
}
那個是我的結果的那一刻:
Finded: #"*Part*":https://pure1.pdf** "Part1":https://pure2.pdf** "Part2":https://pure3.pdf** "Part3":https://pure4.pdf#
Finded: # "*WZ* _(wydanie)_":https://pure7.pdf#
Finded: # "*Close*":https://pure11.pdf** "Close1":https://pure12.pdf#
Finded:
但我會想獲得後續輸出:
Finded: #"*Part*":https://pure1.pdf** "Part1":https://pure2.pdf** "Part2":https://pure3.pdf** "Part3":https://pure4.pdf
Finded: #"*Fakt*":https://pure5.pdf** "Fakt1\":https://pure5.pdf** "Fakt2":https://pure6.pdf
Finded: # "*WZ* _(wydanie)_":https://pure7.pdf
Finded: # "*ZA*":https://pure8.pdf** "PA":https://pure9.pdf
Finded: # "*Close*":https://pure11.pdf** "Close1":https://pure12.pdf
Finded: # *Stany*\":https://pure13.pdf</text><version>7</version><author id=\"1\" name=\"UserName LastName Admin\"/><comments></comments><created_on>2015-11-26T15:08:26Z< created_on><updated_on>2015-11-30T15:44:00Z</updated_on></wiki_page>"
請問您可以以可讀格式發佈輸入嗎?謝謝! – zolo
@Derek,請考慮接受最適合您的答案。 –