我想要做这样的事情在Android上:我可以使用正则表达式替换Android中的匹配组吗?
来自:
*foo* bar*stuff*
DEST:
<b>foo</b> bar<b>stuff</b>
在C#
,我想创建一个正则表达式并替换:
string text = "*foo* bar*stuff*";
Regex bold = new Regex(@"\*(.+?)\*", RegexOptions.Singleline);
html = bold.Replace(html, new MatchEvaluator(p => string.Format("<b>{0}</b>", p.Groups[1].Value)));
我已阅读Android的java.util.regex.Matcher
documentation并且它说replace()
方法用(常量)字符串替换整个匹配。有没有一种方法可以用引用这个事件的组来替换每个事件?
他们有多好**没有提到**这在文档中!谢谢! – Axarydax 2011-02-16 09:23:23