【问题标题】:extracting headings followed by text提取标题后跟文本
【发布时间】:2016-02-22 08:43:38
【问题描述】:

我想在每个标题之后编写提取段落的代码。

例如,考虑以下输入文档:

黑盒测试

在不了解应用程序内部工作原理的情况下进行测试的技术称为黑盒测试。

白盒测试

白盒测试是对代码内部逻辑和结构的详细调查。

灰盒测试

灰盒测试是一种在对应用程序内部工作了解有限的情况下测试应用程序的技术。

作为输出,我想要三个带有相应标题的单独段落= 协会:

output 1    Black-Box Testing

The technique of testing without having any knowledge of the interior workings of the application is called black-box testing. 

output 2  White-Box Testing

White-box testing is the detailed investigation of internal logic and structure of the code. 

output 3  Grey-Box Testing

Grey-box testing is a technique to test the application with having a limited knowledge of the internal workings of an application. 

请指导。

【问题讨论】:

  • 为了自己解决,你做了哪些搜索/努力?
  • 从您提供的浮动文本示例来看,如何将标题与段落文本分开并不明显。

标签: java doc paragraph heading


【解决方案1】:

您可以使用 '\n' 分割文档:
输出应该是一个包含 6 个元素的数组

String[] parts = document.split("\\n");
String part1 = parts[0]; // Black-Box Testing
String part2 = parts[1]; // The technique of testin...
String part3 = parts[2]; // White-Box Testing
String part4 = parts[3]; // White-box testing is the...
...
...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-15
    • 1970-01-01
    • 2019-11-05
    相关资源
    最近更新 更多