태그문자를 text로 또는 text를 태그문자로 변경하는 함수 (ex. <,>, ,\r\n,\t)
태그문자를 text로 또는 text를 태그문자로 변경하는 함수 (ex. <,>, ,\r\n,\t)
function getTextToHtml(txt) {
txt = nvl(txt, '');
txt = txt.replace(/</gi, "<");
txt = txt.replace(/>/gi, ">");
txt = txt.replace(/ /gi, " ");
txt = txt.replace(/\r\n/gi, "<br>");
txt = txt.replace(/\t/gi, " ");
txt = txt.replace(/r/gi, "<br>");
txt = txt.replace(/n/gi, "<br>");
return txt;
}
----
// 180308 html 태그 정보가 담긴 text 목록인지 여부 확인
function getHtmlToTextGu(txt) {
if ( /</i.test(txt) || />/i.test(txt) || / /i.test(txt)
// <로 시작해서 >로 끝나는 태그들이 있는지 확인 (ex. <br>, <br/>, <p>, <span>)
|| (<(\/)?([a-zA-Z]*)(\s[a-zA-Z]*=[^>]*)?(\s)*(\/)?>)/i.test(txt)){
return true;
}
return false;
}
// 180308 text를 html 태그로 변경하도록 처리
function getHtmlToText(txt) {
txt = nvl(txt, '');
txt = txt.replace(/</gi, "<");
txt = txt.replace(/>/gi, ">");
txt = txt.replace(/ /gi, "\t");
txt = txt.replace(/ /gi, " ");
txt = txt.replace(/<br>/gi, "\n");
txt = txt.replace(/<br\/>/gi, "\n");
//<br> 태그를 제외한 <로 시작해서 >로 끝나는 태그들을 공백으로 처리할 때 사용 (ex. <p>, <span>)
txt = txt.replace(/<(\/)?([a-zA-Z]*)(\s[a-zA-Z]*=[^>]*)?(\s)*(\/)?>/gi, "<");
return txt;
}