gpt4 book ai didi

java - SOQL 查询字符串的正则表达式

转载 作者:行者123 更新时间:2023-12-01 15:07:51 24 4
gpt4 key购买 nike

我有以下 SOQL 查询:

选择描述,(从联系人中选择姓名、ID),帐户.名称,(从联系人中选择 ID)从帐户

我想在java中应用正则表达式来提取以下内容 -

从帐户中选择描述、帐户名称

最佳答案

根据给定的表达式定制快速解决方案:

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");

关于java - SOQL 查询字符串的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12740955/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com