public boolean replaceKfm (String label, boolean aKeep, String aBefore, String aAfter)
{
privateCheckHtml();
// This regexp ensures that start tag is before end tag.
MatchResult elementM = null;
String p = "";
try {
p = "(" + cmdPattern("Kfm", label) + ")" /*group 1: start tag*/
// This seems very suspect (WARNING: it can cause StackOverflow Errors!):
// + "((?:.|\\n)*?)" /*group 2: content*/
// lets try: .*?
+ "(.*?)" /*group 2: content replaced*/
+ "(" + "\\</Kfm\\s*\\>" + ")"; /*group 3: end tag */
elementM = RegExp.match(p, html, false, true);
} catch(Error e) {
mLog.error(
"Template::replace,RegExp.match caused Error: " + e + "\n"
+ "Arguments: p = '" + p + "'\n"
+ "html = '" + html + "'");
return false;
}
final int starttagI = 1;
final int contentI = 2;
final int endtagI = 3;
if(elementM == null) return false;
String replacement = aBefore + (aKeep ? elementM.group(contentI) : "") + aAfter;
if(domark) {
//D KFMSystem.log.detail("replaceKfm: mark!");
replacement = markTag(elementM.group(starttagI))
+ replacement + markTag(elementM.group(endtagI));
}