| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 15686
- 알고리즘고득점Kit
- 프로그래머스
- 정렬
- 그래프탐색
- 1932
- Java
- 구현
- 완전탐색
- 깃허브 프로필
- dfs
- 그래프
- 토마토
- GIT
- Lv2
- 이코테
- 월간 코드 챌린지 시즌1
- BFS
- 조합
- 백준
- 프로그래멋
- 알고리즘
- 분할정복
- 깃허브
- 자바
- DP
- Python
- Summer/Winter Coding(~2018)
- 정수 삼각형
- 다익스트라
Archives
- Today
- Total
갱스터하우스
자바 split(".") 안 됨 본문
백준 20291번을 풀다 "."을 기준으로 문자열을 슬라이싱하기위해 split을 썼는데 슬라이싱이 안 되었다.
// 변경 이전
String tmp = br.readLine().split(".")[1];
알고보니 split 메서드는 파라미터로 regx, 즉 정규표현식을 입력받는다.
정규표현식에서 "."의 의미는 임의의 한 문자를 의미한다.
그러므로 "." 의미로 쓰려면 "[.]" 또는 "\\." 로 작성해야한다.
// 변경 이후
String tmp = br.readLine().split("\\.")[1];
참고
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html
String (Java Platform SE 8 )
Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argum
docs.oracle.com