如何从查询中检索特殊字符串如下:
SELECT * from Employees where yearNumber_MO = $$TestCheck_EmployeeMonth \n\t and TESTING_STATUS = $$TestCheck_EmployeeMonth_Group \n\t and WorkflowName = '$PMWorkName' \n\t and CUSTOMFIELD = '$$TestCheck_EmployeeMonth_Region' \n\t and Type = '$$TestCheck_EmployeeMonth_Type' \n\t )
想要上面的返回stringarray with
TestCheck_EmployeeMonth, TestCheck_EmployeeMonth_Group, PMWorkName, TestCheck_EmployeeMonth_Region, TestCheck_EmployeeMonth_Type
答案 0 :(得分:0)
您可以尝试使用正则表达式 (?<=[$]{1,2})[a-zA-Z_]+
Matcher matcher = Pattern.compile("(?<=[$]{1,2})[a-zA-Z_]+").matcher("SELECT * from Employees where yearNumber_MO = $$TestCheck_EmployeeMonth \\n\\t and TESTING_STATUS = $$TestCheck_EmployeeMonth_Group \\n\\t and WorkflowName = '$PMWorkName' \\n\\t and CUSTOMFIELD = '$$TestCheck_EmployeeMonth_Region' \\n\\t and Type = '$$TestCheck_EmployeeMonth_Type' \\n\\t )");
List<String> result = new ArrayList<>();
while(matcher.find()) {
result.add(matcher.group());
}
return result;