regular expression

Edit
regular_expressions_cheat_sheet.png

학습

도움사이트

예제

Java 정규식

HTML추출

Pattern p = Pattern.compile("\\<(\\/?)(\\w+)*([^<>]*)>");
Matcher m = p.matcher(body);

body = m.replaceAll("");

String content = str.replaceAll("<(/)?([a-zA-Z]*)(\\s[a-zA-Z]*=[^>]*)?(\\s)*(/)?>", "");

str.replaceAll("(?:<!.*?(?:--.*?--\\s*)*.*?>)|(?:<(?:[^>'\"]*|\".*?\"|'.*?')+>)","");

그림파일 추출

String source = "<img src=\"
String pattern = ")";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(source);
System.out.println();
while(m.find()) System.out.println(m.group());