java - 检索两个符号之间的数据?

标签 java

任何人都可以帮助获取两个符号之间的数据,例如,我的文件中的数据为

 /*
  ////////////////////////////////////////////////////////////////////////////////////
  //Sistema: Abanks
  //Modulo:  Bus de Integracion (Capa de servicio - TDP)
  //Usuario: ALFA / IVSO / RIAP / LEDA
  //Fecha de Elaboración: 01-06-2016 / 01-01-2017
  //Variables:
  //Modificacion: MOD 001 13.01.2017 ALFA/IVSO/RIAP
                  MOD 002 26.05.2017 RIAP Menus Permitidos para el canal HOMEJUR
                  MOD 003 31.05.2017 RIAP
   ////////////////////////////////////////////////////////////////////////////////////
  */

我需要/* data */这两个符号之间的输出。

最佳答案

试试这个代码:

String input = "/*\n  /// Content goes here ///\n*/ stuff stuff /* More Content */";
String pattern = "/\\*(.*?)\\*/";

Pattern r = Pattern.compile(pattern, Pattern.DOTALL);

Matcher m = r.matcher(input);
while (m.find()) {
   System.out.println("Found content:\n " + m.group(1));
}

输出:

Found content:

  /// Content goes here ///

Found content:
  More Content 

此处演示:

Rextester

关于java - 检索两个符号之间的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44817579/

相关文章:

java - Android - 如何将工具栏固定在 AppBar 的顶部

java - 文件写入打印机、文件输出流

java - ApplicationBinder 中泛型类型的 JAX-RS Bind 实现

java ee bean 验证

java - 如何衡量JAVA MetaSpace?

java - Android MaterialCardView 切角样式

java - 我被作业困住了,无法在 sqlite 数据库 android 中保存图像路径

java - 方法的编写顺序重要吗?

java - 在 WLISTBOX ZK 中选择行时如何将单元格设置为可编辑?

java - 二进制转十进制并翻转0和1 JAVA