private static String addAfterLinesContainingEx(String origStr, String findThis, String addThat,
		String eolMarker, boolean notInsideTag) {
		if (origStr == null) {
			return null;
		}
		if (findThis == null) {
			return origStr;
		}
		if ((addThat == null) || "".equals(addThat)) {
			return origStr;
		}
		if ((eolMarker == null) || "".equals(eolMarker)) {
			return origStr;
		}
		if ("".equals(findThis)) {
			return replaceAll(origStr, "\n", "\n" + addThat) + "\n" + addThat;
		}
		StringBuilder result = new StringBuilder();
		int index = origStr.indexOf(findThis);
		while (index >= 0) {
			if (notInsideTag) {
				if ((index > 0) && origStr.charAt(index - 1) == '>') {
					index = origStr.indexOf(findThis, index + 1);
					continue;
				}
			}
			int eol = origStr.indexOf(eolMarker, index);
			if (eol < 0) {
				result.append(origStr);
				result.append(eolMarker);
				origStr = "";
			} else {
				result.append(origStr.substring(0, eol + eolMarker.length()));
				// TODO :: improve speed by not calling substring but keeping track of start!
				origStr = origStr.substring(eol + eolMarker.length());
			}
			result.append(addThat);
			index = origStr.indexOf(findThis);
		}
		result.append(origStr);
		return result.toString();
	}
private static String addAfterLinesContainingEx(String origStr, String findThis, String addThat,
		String eolMarker, boolean notInsideTag) {
		if (origStr == null) {
			return null;
		}
		if (findThis == null) {
			return origStr;
		}
		if ((addThat == null) || "".equals(addThat)) {
			return origStr;
		}
		if ((eolMarker == null) || "".equals(eolMarker)) {
			return origStr;
		}
		if ("".equals(findThis)) {
			return replaceAll(origStr, "\n", "\n" + addThat) + "\n" + addThat;
		}
		StringBuilder result = new StringBuilder();
		int index = origStr.indexOf(findThis);
		while (index >= 0) {
			if (notInsideTag) {
				if ((index > 0) && origStr.charAt(index - 1) == '>') {
					index = origStr.indexOf(findThis, index + 1);
					continue;
				}
			}
			int eol = origStr.indexOf(eolMarker, index);
			if (eol < 0) {
				result.append(origStr);
				result.append(eolMarker);
				origStr = "";
			} else {
				result.append(origStr.substring(0, eol + eolMarker.length()));
			
				origStr = origStr.substring(eol + eolMarker.length());
			}
			result.append(addThat);
			index = origStr.indexOf(findThis);
		}
		result.append(origStr);
		return result.toString();
	}
private static string addafterlinescontainingex(string origstr, string findthis, string addthat, string eolmarker, boolean notinsidetag) { if (origstr == null) { return null; } if (findthis == null) { return origstr; } if ((addthat == null) || "".equals(addthat)) { return origstr; } if ((eolmarker == null) || "".equals(eolmarker)) { return origstr; } if ("".equals(findthis)) { return replaceall(origstr, "\n", "\n" + addthat) + "\n" + addthat; } stringbuilder result = new stringbuilder(); int index = origstr.indexof(findthis); while (index >= 0) { if (notinsidetag) { if ((index > 0) && origstr.charat(index - 1) == '>') { index = origstr.indexof(findthis, index + 1); continue; } } int eol = origstr.indexof(eolmarker, index); if (eol < 0) { result.append(origstr); result.append(eolmarker); origstr = ""; } else { result.append(origstr.substring(0, eol + eolmarker.length())); origstr = origstr.substring(eol + eolmarker.length()); } result.append(addthat); index = origstr.indexof(findthis); } result.append(origstr); return result.tostring(); }