任何人都可以帮助获取两个符号之间的数据,例如,我的文件中的数据为
/*
////////////////////////////////////////////////////////////////////////////////////
//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/