我在regex
中很弱,我认为我已经分配的任务需要regex
。 假设我有以下字符串#B#Objectives:#B#We aimed to review how personality characteristics contribute to the onset, maintenance or modulation of.#B#Method:#B#The databases Medline and PsychINFO were examined from 1967 to 2012 to
。用html div取代某些模式
现在我的要求是用<div class="format">anystring</div>
替换#B#anystring#B#
。
我认为regex
是必需的,但我不知道什么是正则表达式。
请给出任何建议。
更新
String regex="#B#";
String textFormated = text.replaceAll(regex,"<div class='formated'>");
System.out.println(textFormated);
这就是我想直到now.It刚刚替换#B#
与<div class='formated'>
但如果:#B#
被发现有轻微的并发症,增加股利div.The结束的结束应该加入但这两个正则表达式如何一起使用。
你有什么已经做了?你试过的任何代码? – Howard 2013-05-07 05:30:07