여러 줄로 된 HTML 파일에서 빈 HTML 요소를 찾는 데 문제가 있습니다. 내 정규 표현식은 다음과 같습니다.Java regexp 패턴 빈 HTML/XML 요소 찾기
Pattern pattern = Pattern.compile("<([a-zA-Z][a-zA-Z0-9]*)[^>]*?>[\\s]*?</\\1>");
Matcher matcher = pattern.matcher(htmlOut);
while (matcher.find())
{
htmlOut = matcher.replaceAll("");
matcher = pattern.matcher(htmlOut);
}
문제는 빈 태그 중 하나와 일치하지 않습니다.
참고 : 동일한 정규 표현식 <([a-zA-Z][a-zA-Z0-9]*)[^>]*?>[\s]*?</\1>
은 (는) 장엄한 텍스트로 작동합니다.
어떤 방법이라도?
Obligatory Regex/Html reply : @stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – glenatron
@ 글쓴이 : 빈 태그 제거하기 물론 정규 표현식으로 가능한 영역에서. HTML도 있습니다. –