我有以下 SOQL 查询:
SELECT Description,(Select Name,Id from Contacts) , Account.Name, (Select Id from Contacts) from Account
我想在java中应用正则表达式来提取以下内容 -
SELECT Description, Account.Name from Account
我有以下 SOQL 查询:
SELECT Description,(Select Name,Id from Contacts) , Account.Name, (Select Id from Contacts) from Account
我想在java中应用正则表达式来提取以下内容 -
SELECT Description, Account.Name from Account
根据给定表达式定制的快速解决方案:
String query = "SELECT Description,(Select Name,Id from Contacts) , Account.Name, (Select Id from Contacts) from Account";
// Remove all subqueries (things in parenthesis)
// Remove doubled commas (even with space in between)
// Remove a comma before the from
String answer = query
.replaceAll("\\(.*?\\)", "")
.replaceAll(",\\s*,", ",")
.replaceAll(",\\s*from", " from");