我想要输出正则表达式
|Term Loan-amount or |Bill Purchase / Discounting (Inland)-amount or |PARTNER_NAME-PAN
只能以这种方式接受。
答案 0 :(得分:0)
我们不清楚你的问题。如果符合您的要求,您可以尝试以下选项。
尝试这个只接受一个
String str = "abc |PARTNER_NAME-PAN xyz";
Pattern patter = Pattern
.compile("(\\|Term Loan-amount|\\|Bill Purchase / Discounting \\(Inland\\)-amount|\\|PARTNER_NAME-PAN)");
Matcher matcher = patter.matcher(str);
if (matcher.find()) {
System.out.println("accept");
System.out.println(matcher.group());
}
- 编辑 -
或针对任何|abc-amount
String str = "abc |Bill Purchase / Discounting (Inland)-amount xyz";
Pattern patter = Pattern.compile("(\\|(.*)-amount|\\|PARTNER_NAME-PAN)");
Matcher matcher = patter.matcher(str);
if (matcher.find()) {
System.out.println("accept");
System.out.println(matcher.group());
}
输出
accept
|Bill Purchase / Discounting (Inland)-amount