0

以下の SOQL クエリがあります。

SELECT Description,(Select Name,Id from Contacts) , Account.Name, (Select Id from Contacts) from Account

Javaで正規表現を適用して、以下を抽出したい-

SELECT Description, Account.Name from Account

4

1 に答える 1

1

与えられた式に合わせたクイックソリューションカスタム:

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");
于 2012-10-05T06:55:49.433 に答える