如何在顶点代码中找到符合我的开始和结束条件的所有字符串

时间:2014-04-04 11:11:04

标签: salesforce apex-code visualforce apex

我的代码是

String str = 'You can <strong>use a Matcher to find </strong>all matches to a regular repression';
// find all words starting with <strong> and ends with</strong>. 
// RegEx backslash should be escaped with an additional one.
Pattern Pattern p = Pattern.compile('(?i)(<strong>)\\w*(</strong>)');
Matcher m = p.matcher(str);
while (m.find()) { // find next match 
    String match = m.group();
    result=match+result+'<br/>';
}

0 个答案:

没有答案