자바 html 태그 제거
                                            
 3970 단어  html 태그
                    
import java.util.regex.Matcher; 
import java.util.regex.Pattern; 
public class HTMLSpirit{ 
    public static String delHTMLTag(String htmlStr){ 
        String regEx_script="<script[^>]*?>[\\s\\S]*?<\\/script>"; //  script       
        String regEx_style="<style[^>]*?>[\\s\\S]*?<\\/style>"; //  style       
        String regEx_html="<[^>]+>"; //  HTML         
         
        Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE); 
        Matcher m_script=p_script.matcher(htmlStr); 
        htmlStr=m_script.replaceAll(""); //  script   
         
        Pattern p_style=Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE); 
        Matcher m_style=p_style.matcher(htmlStr); 
        htmlStr=m_style.replaceAll(""); //  style   
         
        Pattern p_html=Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE); 
        Matcher m_html=p_html.matcher(htmlStr); 
        htmlStr=m_html.replaceAll(""); //  html   
        return htmlStr.trim(); //        
    } 
} 자바 에서 웹 페이지 HTML 표 시 를 없 애 는 방법 자바 에서 웹 페이지 의 HTML 표 시 를 제거 하 는 방법: /** * 문자열 에 있 는 html 코드 를 제거 합 니 다.
* 데 이 터 를 규범화 시 켜 야 한다.예 를 들 어 작은 번호 보다 조합 해 야 한다.그렇지 않 으 면 단체 에 의 해 오 살 될 것 이다. * * @param content * 내용. * @return 제거 후 내용 */
public static String stripHtml(String content) { 
// <p>        
content = content.replaceAll("<p .*?>", "\r
"); 
// <br><br/>      
content = content.replaceAll("<br\\s*/?>", "\r
"); 
//      <>      
content = content.replaceAll("\\<.*?>", ""); 
//   HTML 
// content = HTMLDecoder.decode(content); 
return content; 
}이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Grouping Content in HTML주로 여러가지 목록을 나열할 때 사용합니다. <ol> 태그 ordered list의 약자로 순서가 있는 목록을 뜻합니다. <ul> 태그 unordered list의 약자로 순서가 없는 목록을 뜻합니다. <li> 태그...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.