私は非常に苦手で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
。
今、私の要件は に置き換えること#B#anystring#B#
です<div class="format">anystring</div>
。
必要だと思いますregex
が、正規表現がどうなるかわかりません。
何か提案をお願いします。
更新しました
String regex="#B#";
String textFormated = text.replaceAll(regex,"<div class='formated'>");
System.out.println(textFormated);
これは私が今まで試したことです。置き換え#B#
ただけ<div class='formated'>
ですが、divの末尾を追加するのは少し複雑です.が見つかった場合はdivの末尾を追加する必要があります:#B#
.しかし、これらの両方の正規表現を一緒に使用する方法.