参考:
https://iwritecrappycode.wordpress.com/2012/06/29/extracting-strings-with-regex-in-salesforce-apex/
Pattern p = Pattern.compile('\\{([^}]*)\\}'); //带括号
// Pattern p = Pattern.compile('(?i)(?m)(?<=\\{).*?(?=\\})'); //不带括号
Matcher m = p.matcher(s);
List<String> apis = new List<String>();
while (m.find())
{
apis.add(m.group());
}
System.debug('获取所有字段'+apis);
本文介绍了一种在Salesforce Apex中利用正则表达式从字符串中提取特定模式的方法。通过示例代码展示了如何定义匹配模式、进行匹配操作以及收集匹配结果。
487

被折叠的 条评论
为什么被折叠?



