我有一个 DefaultStyledDocument,里面有一个格式化的文本。我还有一个函数,它用 Pattern-Matcher 分割内容(作为纯文本)。
我需要一个函数,它从拆分输出中生成新的完整 DefaultStyledDocuments
DefaultStyledDocument doc = new DefaultStyledDocument();
Functions.loadRtfToDocument(rtfText, doc); //rtfText is a RTF-String
Pattern pattern = Pattern.compile("^((\\s*)•)", Pattern.MULTILINE);
Matcher matcher = pattern.matcher(plainText);
while(matcher.find()){
int start = matcher.start();
int end = matcher.end();
DefaultStyledDocument target = new DefaultStyledDocument();
//Fill the target with the styled text (from start to end)
}