일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- vscode
- JavaScript
- maVen
- import
- Windows 10
- context
- 네트워크
- Windows
- bash
- Eclipse
- Quartz
- tomcat
- xargs
- web.xml
- Source
- ssh
- plugin
- 줄바꿈 문자
- resource
- profile
- grep
- GIT
- 단축키
- netsh
- Mac
- VirtualBox
- find
- IntelliJ
- port
- lsof
- Today
- Total
develog
정규표현식 #1 본문
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestMain {
public static void main(String[] args) {
System.out.println("START");
System.out.println("-------------------------------------");
String str = "<a href='javascript:void(0);' onclick='skip_navigation('content');'>본문 영역으로 바로가기</a>";
System.out.println("str : " + str);
String regex = "<.*?>";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(str);
String ret = null;
while (matcher.find()) {
System.out.print(" ");
System.out.print(matcher.start() + ", " + matcher.end());
System.out.print(", " + str.substring(matcher.start(), matcher.end()));
System.out.println();
ret = str.replaceAll(regex, "");
}
System.out.println("ret : " + ret);
System.out.println("-------------------------------------");
System.out.println("END");
}
}
'Dev > Java' 카테고리의 다른 글
logger.error (0) | 2013.05.29 |
---|---|
[Java] log4j, add appender in source code (0) | 2013.05.29 |
[java] html tag 제거 (0) | 2013.05.26 |
Collection List<Map> sort (0) | 2013.05.16 |
Web scraper open source (0) | 2013.05.16 |