以下の 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");