Front/JS & jQuery

[js][datatables] 엑셀 변환 시 html코드 처리

오선지♬ 2025. 2. 23. 11:50
728x90
반응형
// HTML 태그 제거 및 줄바꿈 처리
	            let text = data
	                .replace(/<br[^>]*>/g, "\r\n") // <br> → 개행 문자로 변환
	                .replace(/<[^>]*>/g, "") // 모든 HTML 태그 제거
	                .replace(/&nbsp;/g, " ") // &nbsp;를 공백으로 변경
	                .trim(); // 앞뒤 공백 제거
728x90
반응형