[정규표현식] java Regular Expression
2015. 12. 10. 11:14ㆍ프로그래밍/JAVA
- 목차
[펌] http://lng1982.tistory.com/141
정규표현식은 특정한 규칙을 가지는 문자를 표현하는데 사용하는 형식 언어이다.
정규표현식을 잘 모를 때에는 validation 체크가 상당히 고단하고, 지루했지만 정규표현식을 자유 자재로 다룰 줄 알게 되면 상당한 시간을 단축할 수 있고, 유용하며 코드가 깔끔해 진다.
가끔 표현식을 까먹는 경우가 있어 이곳에 표로 정리를 하고, 각 표현식에 대한 테스트 케이스를 만들어 보았다.
표현식 | 설명 |
^ | 문자열의 시작 |
$ | 문자열의 종료 |
. | 임의의 한 문자 (문자의 종류 가리지 않음) 단, \ 는 넣을 수 없음 |
* | 앞 문자가 없을 수도 무한정 많을 수도 있음 |
+ | 앞 문자가 하나 이상 |
? | 앞 문자가 없거나 하나있음 |
[] | 문자의 집합이나 범위를 나타내며 두 문자 사이는 - 기호로 범위를 나타낸다. []내에서 ^가 선행하여 존재하면 not 을 나타낸다. |
{} | 횟수 또는 범위를 나타낸다. |
() | 소괄호 안의 문자를 하나의 문자로 인식 |
| | 패턴 안에서 or 연산을 수행할 때 사용 |
\s | 공백 문자 |
\S | 공백 문자가 아닌 나머지 문자 |
\w | 알파벳이나 숫자 |
\W | 알파벳이나 숫자를 제외한 문자 |
\d | 숫자 [0-9]와 동일 |
\D | 숫자를 제외한 모든 문자 |
\ | 정규표현식 역슬래시(\)는 확장 문자 역슬래시 다음에 일반 문자가 오면 특수문자로 취급하고 역슬래시 다음에 특수문자가 오면 그 문자 자체를 의미 |
(?i) | 앞 부분에 (?i) 라는 옵션을 넣어주면 대소문자를 구분하지 않음 |
자바스크립트 또한 자바의 정규표현식과 대동소이하다.
아래 사용법만 익히면 쉽게 사용할 수 있다.
var filter = /[a-z]+/;
if (filter.test("a") == true) {
alert("success");
} else {
alert("fail");
}
package regular; | |
import static org.hamcrest.CoreMatchers.*; | |
import static org.junit.Assert.*; | |
import java.util.regex.Pattern; | |
import org.junit.Test; | |
/** | |
* @FileName : RegularTest.java | |
* @Project : test_project | |
* @Date : 2013. 5. 2. | |
* @작성자 : 이남규 | |
* @프로그램설명 : | |
*/ | |
public class RegularTest { | |
/** | |
* <pre> | |
* 문자열시작테스트 ^ | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 문자열시작테스트() { | |
String regex = "^[a-zA-Z]{3}[0-9]+"; | |
assertThat(true, is(matched(regex, "aAb09"))); | |
assertThat(true, is(matched(regex, "aaa09"))); | |
assertThat(true, is(matched(regex, "AAA09"))); | |
assertThat(true, is(matched(regex, "zzZ09"))); | |
assertThat(true, is(matched(regex, "zzZ00"))); | |
assertThat(false, is(matched(regex, "zzZ"))); | |
assertThat(false, is(matched(regex, "12a"))); | |
assertThat(false, is(matched(regex, "aaaa09"))); | |
} | |
/** | |
* <pre> | |
* 문자열의종료 $ | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 문자열의종료() { | |
String regex = "a{2}$"; | |
assertThat(true, is(matched(regex, "aa"))); | |
assertThat(false, is(matched(regex, "aa11"))); | |
} | |
/** | |
* <pre> | |
* 임의의한문자를나타냄 . | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 임의의한문자를나타냄() { | |
String regex = "aaa.bb"; | |
assertThat(true, is(matched(regex, "aaa1bb"))); | |
assertThat(true, is(matched(regex, "aaaCbb"))); | |
assertThat(true, is(matched(regex, "aaaZbb"))); | |
assertThat(true, is(matched(regex, "aaa!bb"))); | |
assertThat(true, is(matched(regex, "aaa@bb"))); | |
assertThat(true, is(matched(regex, "aaa#bb"))); | |
assertThat(true, is(matched(regex, "aaa$bb"))); | |
assertThat(true, is(matched(regex, "aaa%bb"))); | |
assertThat(true, is(matched(regex, "aaa^bb"))); | |
assertThat(true, is(matched(regex, "aaa&bb"))); | |
assertThat(true, is(matched(regex, "aaa*bb"))); | |
assertThat(true, is(matched(regex, "aaa(bb"))); | |
assertThat(true, is(matched(regex, "aaa)bb"))); | |
assertThat(true, is(matched(regex, "aaa-bb"))); | |
assertThat(true, is(matched(regex, "aaa+bb"))); | |
assertThat(true, is(matched(regex, "aaa=bb"))); | |
assertThat(false, is(matched(regex, "aaabb"))); | |
assertThat(false, is(matched(regex, "aaa\bb"))); | |
assertThat(false, is(matched(regex, "aaa12bb"))); | |
assertThat(false, is(matched(regex, "aaa$$bb"))); | |
} | |
/** | |
* <pre> | |
* 앞문자가없을수도무한정있을수도있음 * | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 앞문자가없을수도무한정있을수도있음() { | |
String regex = "a*b"; | |
assertThat(true, is(matched(regex, "ab"))); | |
assertThat(true, is(matched(regex, "aaab"))); | |
assertThat(true, is(matched(regex, "aab"))); | |
assertThat(true, is(matched(regex, "b"))); | |
assertThat(false, is(matched(regex, "aabb"))); | |
assertThat(false, is(matched(regex, "aaccdd"))); | |
assertThat(false, is(matched(regex, "a_ab"))); | |
assertThat(false, is(matched(regex, "abcd"))); | |
} | |
/** | |
* <pre> | |
* 앞문자가하나이상 + | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 앞문자가하나이상() { | |
String regex = "abc_A+"; | |
assertThat(true, is(matched(regex, "abc_A"))); | |
assertThat(true, is(matched(regex, "abc_AA"))); | |
assertThat(true, is(matched(regex, "abc_AAA"))); | |
assertThat(false, is(matched(regex, "abc"))); | |
assertThat(false, is(matched(regex, "abc_"))); | |
assertThat(false, is(matched(regex, "abc_AAb"))); | |
assertThat(false, is(matched(regex, "abc_AA1"))); | |
} | |
/** | |
* <pre> | |
* 앞문자가없거나하나있음 ? | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 앞문자가없거나하나있음() { | |
String regex = "abc_B?"; | |
assertThat(true, is(matched(regex, "abc_"))); | |
assertThat(true, is(matched(regex, "abc_B"))); | |
assertThat(false, is(matched(regex, "abc_C"))); | |
assertThat(false, is(matched(regex, "abc_DD"))); | |
assertThat(false, is(matched(regex, "abc_11"))); | |
} | |
/** | |
* <pre> | |
* 문자클래스지정1 [] | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 문자클래스지정1() { | |
String regex = "[a-z0-9]"; | |
assertThat(true, is(matched(regex, "a"))); | |
assertThat(true, is(matched(regex, "b"))); | |
assertThat(true, is(matched(regex, "z"))); | |
assertThat(true, is(matched(regex, "0"))); | |
assertThat(true, is(matched(regex, "8"))); | |
assertThat(false, is(matched(regex, "A"))); | |
assertThat(false, is(matched(regex, "aa"))); | |
assertThat(false, is(matched(regex, "a0"))); | |
assertThat(false, is(matched(regex, "00a"))); | |
} | |
/** | |
* <pre> | |
* 문자클래스지정2 [^] | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 문자클래스지정2() { | |
String regex = "[^a-f1-3]"; | |
assertThat(true, is(matched(regex, "g"))); | |
assertThat(true, is(matched(regex, "h"))); | |
assertThat(true, is(matched(regex, "4"))); | |
assertThat(true, is(matched(regex, "0"))); | |
assertThat(true, is(matched(regex, "9"))); | |
assertThat(false, is(matched(regex, "a"))); | |
assertThat(false, is(matched(regex, "2"))); | |
} | |
/** | |
* <pre> | |
* 횟수또는범위1 {3} | |
* a 3개만 올 수 있음 | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 횟수또는범위1() { | |
String regex = "a{3}b"; | |
assertThat(true, is(matched(regex, "aaab"))); | |
assertThat(false, is(matched(regex, "aab"))); | |
assertThat(false, is(matched(regex, "aaaab"))); | |
assertThat(false, is(matched(regex, "aaaaaaab"))); | |
assertThat(false, is(matched(regex, "aaaaaaabb"))); | |
} | |
/** | |
* <pre> | |
* 횟수또는범위2 {3,} | |
* a 3개 이상 올 수 있음 | |
* <pre> | |
*/ | |
@Test | |
public void 횟수또는범위2() { | |
String regex = "a{3,}b"; | |
assertThat(true, is(matched(regex, "aaab"))); | |
assertThat(true, is(matched(regex, "aaaab"))); | |
assertThat(true, is(matched(regex, "aaaaab"))); | |
assertThat(true, is(matched(regex, "aaaaaaaaaaaaaaaaaaaaaaaaab"))); | |
assertThat(false, is(matched(regex, "aab"))); | |
assertThat(false, is(matched(regex, "ab"))); | |
assertThat(false, is(matched(regex, "b"))); | |
} | |
/** | |
* <pre> | |
* 횟수또는범위3 {3,5} | |
* a 3개 이상 5개 이하 올 수 있음 | |
* <pre> | |
*/ | |
@Test | |
public void 횟수또는범위3() { | |
String regex = "a{3,5}b"; | |
assertThat(true, is(matched(regex, "aaab"))); | |
assertThat(true, is(matched(regex, "aaaab"))); | |
assertThat(true, is(matched(regex, "aaaaab"))); | |
assertThat(false, is(matched(regex, "aaaaaab"))); | |
assertThat(false, is(matched(regex, "aaaaaaaaaaab"))); | |
String regex1 = "a{3,5}."; | |
assertThat(true, is(matched(regex1, "aaab"))); | |
assertThat(false, is(matched(regex1, "aaabb"))); | |
String regex2 = "a{3,5}.{4}"; | |
assertThat(true, is(matched(regex2, "aaabbbb"))); | |
assertThat(false, is(matched(regex2, "aaabbbbb"))); | |
assertThat(false, is(matched(regex2, "aaab"))); | |
assertThat(false, is(matched(regex2, "aaabb"))); | |
assertThat(false, is(matched(regex2, "aaabbb"))); | |
} | |
/** | |
* <pre> | |
* 소괄호문자를하나의문자로인식 () | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 소괄호문자를하나의문자로인식() { | |
String regex = "abc(11){2}"; | |
assertThat(true, is(matched(regex, "abc1111"))); | |
assertThat(false, is(matched(regex, "abc11"))); | |
assertThat(false, is(matched(regex, "ab11"))); | |
assertThat(false, is(matched(regex, "ab111111"))); | |
} | |
/** | |
* <pre> | |
* or연산1 | | |
* | |
* <pre> | |
*/ | |
@Test | |
public void or연산() { | |
String regex = "hello|world"; | |
assertThat(true, is(matched(regex, "hello"))); | |
assertThat(true, is(matched(regex, "world"))); | |
assertThat(false, is(matched(regex, "helloworld"))); | |
assertThat(false, is(matched(regex, "hello|world"))); | |
String regex1 = "(hello|world){1}"; | |
assertThat(true, is(matched(regex1, "hello"))); | |
assertThat(true, is(matched(regex1, "world"))); | |
assertThat(false, is(matched(regex1, "helloworld"))); | |
} | |
/** | |
* <pre> | |
* 알파벳이나숫자 \w | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 알파벳이나숫자() { | |
String regex = "\\w"; | |
assertThat(true, is(matched(regex, "a"))); | |
assertThat(true, is(matched(regex, "Z"))); | |
assertThat(true, is(matched(regex, "4"))); | |
assertThat(false, is(matched(regex, "$"))); | |
assertThat(false, is(matched(regex, "남"))); | |
assertThat(false, is(matched(regex, "12"))); | |
} | |
/** | |
* <pre> | |
* 알파벳이나숫자를제외한문자 \W | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 알파벳이나숫자를제외한문자() { | |
String regex = "\\W"; | |
assertThat(true, is(matched(regex, "@"))); | |
assertThat(true, is(matched(regex, ")"))); | |
assertThat(true, is(matched(regex, "\\"))); | |
assertThat(false, is(matched(regex, "1"))); | |
assertThat(false, is(matched(regex, "a"))); | |
String regex1 = "\\W{3}"; | |
assertThat(true, is(matched(regex1, "!@#"))); | |
assertThat(true, is(matched(regex1, ")(*"))); | |
} | |
/** | |
* <pre> | |
* 숫자만 \d | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 숫자만() { | |
String regex = "\\d"; | |
assertThat(true, is(matched(regex, "1"))); | |
assertThat(true, is(matched(regex, "3"))); | |
assertThat(true, is(matched(regex, "4"))); | |
assertThat(false, is(matched(regex, "a"))); | |
assertThat(false, is(matched(regex, "Z"))); | |
assertThat(false, is(matched(regex, "11"))); | |
} | |
/** | |
* <pre> | |
* 숫자를제외한모든문자 \\D | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 숫자를제외한모든문자() { | |
String regex = "\\D"; | |
assertThat(true, is(matched(regex, "a"))); | |
assertThat(true, is(matched(regex, "한"))); | |
assertThat(true, is(matched(regex, "규"))); | |
assertThat(false, is(matched(regex, "1"))); | |
assertThat(false, is(matched(regex, "3"))); | |
assertThat(false, is(matched(regex, "44"))); | |
} | |
/** | |
* <pre> | |
* 역슬래스테스트 \ | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 역슬래스테스트() { | |
String regex = "a\\sb"; | |
assertThat(true, is(matched(regex, "a b"))); | |
String regex1 = "a\\tb"; | |
assertThat(true, is(matched(regex1, "a b"))); | |
String regex2 = "a\\nb"; | |
assertThat(true, is(matched(regex2, "a\nb"))); | |
} | |
/** | |
* <pre> | |
* 대소문자구분안함 (?i) | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 대소문자구분안함() { | |
String regex = "(?i)abc"; | |
assertThat(true, is(matched(regex, "abc"))); | |
assertThat(true, is(matched(regex, "ABC"))); | |
assertThat(true, is(matched(regex, "aBc"))); | |
String regex1 = "abc"; | |
assertThat(false, is(matched(regex1, "ABC"))); | |
assertThat(false, is(matched(regex1, "abC"))); | |
assertThat(false, is(matched(regex1, "aBc"))); | |
} | |
@Test | |
public void 특수문자테스트() { | |
String regex = "^[a-z0-9A-Z]*@#"; | |
assertThat(true, is(matched(regex, "12@#"))); | |
} | |
/** | |
* <pre> | |
* 영어숫자만 | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 영어숫자만() { | |
String regex = "^[0-9a-zA-Z]*$"; | |
assertThat(true, is(matched(regex, "1212dafda"))); | |
assertThat(true, is(matched(regex, "1"))); | |
assertThat(true, is(matched(regex, "a"))); | |
assertThat(true, is(matched(regex, "Z"))); | |
assertThat(true, is(matched(regex, ""))); | |
assertThat(false, is(matched(regex, "한"))); | |
} | |
/** | |
* <pre> | |
* 한글만 | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 한글만() { | |
String regex = "^[가-힣]*$"; | |
assertThat(true, is(matched(regex, "가"))); | |
assertThat(true, is(matched(regex, "가나다"))); | |
assertThat(true, is(matched(regex, "가나다라하햐호호유"))); | |
assertThat(true, is(matched(regex, "뷁"))); | |
assertThat(true, is(matched(regex, "힔"))); | |
assertThat(false, is(matched(regex, "1"))); | |
assertThat(false, is(matched(regex, "a"))); | |
assertThat(false, is(matched(regex, "Z"))); | |
} | |
/** | |
* <pre> | |
* replaceAllTest | |
* 한글 삭제 | |
* <pre> | |
*/ | |
@Test | |
public void replaceAllTest() { | |
String value = "abc한123"; | |
String hangulDeleteValue = value.replaceAll("[가-힣]*", ""); | |
assertThat(true, is(matched(hangulDeleteValue, "abc123"))); | |
} | |
/** | |
* <pre> | |
* 이메일체크 | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 이메일체크() { | |
String emailRegex = "^[a-z0-9A-Z_-]*@[a-z0-9A-Z]*.[a-zA-Z.]*$"; | |
assertThat(true, is(matched(emailRegex, "lng1982@naver.com"))); | |
assertThat(true, is(matched(emailRegex, "lng1982@naver.co.kr"))); | |
assertThat(true, is(matched(emailRegex, "lng1982@daum.net"))); | |
assertThat(true, is(matched(emailRegex, "lng1982@test.org"))); | |
assertThat(false, is(matched(emailRegex, "lng1982$@naver.com"))); | |
assertThat(false, is(matched(emailRegex, "lng1982naver.com"))); | |
assertThat(false, is(matched(emailRegex, "lng1982naver.com12"))); | |
} | |
/** | |
* <pre> | |
* 휴대폰체크 | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 휴대폰체크() { | |
String phoneRegex = "^0\\d{2}"; | |
assertThat(true, is(matched(phoneRegex, "010"))); | |
assertThat(true, is(matched(phoneRegex, "011"))); | |
assertThat(true, is(matched(phoneRegex, "019"))); | |
assertThat(false, is(matched(phoneRegex, "111"))); | |
assertThat(false, is(matched(phoneRegex, "11a"))); | |
String phoneRegex1 = "^0\\d{2}\\d{3,4}"; | |
assertThat(true, is(matched(phoneRegex1, "010866"))); | |
assertThat(true, is(matched(phoneRegex1, "0108667"))); | |
assertThat(false, is(matched(phoneRegex1, "01086677"))); | |
assertThat(false, is(matched(phoneRegex1, "010866771"))); | |
String phoneRegex2 = "^0\\d{2}\\d{3,4}\\d{4}$"; | |
assertThat(true, is(matched(phoneRegex2, "01086677100"))); | |
assertThat(true, is(matched(phoneRegex2, "01086677101"))); | |
assertThat(true, is(matched(phoneRegex2, "0108667710"))); | |
assertThat(false, is(matched(phoneRegex2, "010866771000"))); | |
assertThat(false, is(matched(phoneRegex2, "01086677100a"))); | |
assertThat(false, is(matched(phoneRegex2, "11086677100a"))); | |
} | |
/** | |
* <pre> | |
* 주민등록번호 | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 주민등록번호() { | |
String regex = "^\\d{6}(1|2|3|4)"; | |
assertThat(true, is(matched(regex, "8210111"))); | |
assertThat(true, is(matched(regex, "8210112"))); | |
assertThat(true, is(matched(regex, "8210113"))); | |
assertThat(true, is(matched(regex, "8210114"))); | |
assertThat(false, is(matched(regex, "8210115"))); | |
assertThat(false, is(matched(regex, "82101151"))); | |
String regex1 = "^\\d{6}(1|2|3|4)\\d{6}$"; | |
assertThat(true, is(matched(regex1, "8210201111111"))); | |
assertThat(true, is(matched(regex1, "8210202222222"))); | |
assertThat(true, is(matched(regex1, "8210203333333"))); | |
assertThat(true, is(matched(regex1, "8210204444444"))); | |
assertThat(false, is(matched(regex1, "8210205555555"))); | |
assertThat(false, is(matched(regex1, "82102055555551"))); | |
assertThat(false, is(matched(regex1, "8210205a55551"))); | |
assertThat(false, is(matched(regex1, "8210205\55551"))); | |
String regex2 = "^\\d{6}[1-4]\\d{6}$"; | |
assertThat(true, is(matched(regex2, "8210201111111"))); | |
assertThat(true, is(matched(regex2, "8210202111111"))); | |
assertThat(true, is(matched(regex2, "8210203111111"))); | |
assertThat(true, is(matched(regex2, "8210204111111"))); | |
} | |
/** | |
* <pre> | |
* 아이피체크 | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 아이피체크() { | |
String regex = "^\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}$"; | |
assertThat(true, is(matched(regex, "172.18.167.92"))); | |
assertThat(true, is(matched(regex, "172.181.167.921"))); | |
assertThat(true, is(matched(regex, "1.181.167.921"))); | |
assertThat(true, is(matched(regex, "1.1.167.921"))); | |
assertThat(true, is(matched(regex, "1.1.7.921"))); | |
assertThat(true, is(matched(regex, "1.1.7.9"))); | |
assertThat(false, is(matched(regex, "1721.181.167.921"))); | |
assertThat(false, is(matched(regex, "172.1811.167.921"))); | |
assertThat(false, is(matched(regex, "172.181.1671.921"))); | |
assertThat(false, is(matched(regex, "172.181.167.9211"))); | |
} | |
/** | |
* <pre> | |
* 파일확장자체크 | |
* | |
* <pre> | |
*/ | |
@Test | |
public void 파일확장자체크() { | |
String regex = "^\\S+.(?i)(png|jpg|bmp|gif)$"; | |
assertThat(true, is(matched(regex, "test.png"))); | |
assertThat(true, is(matched(regex, "test.jpg"))); | |
assertThat(true, is(matched(regex, "test.bmp"))); | |
assertThat(true, is(matched(regex, "test.gif"))); | |
assertThat(true, is(matched(regex, "test1#$adf한.gif"))); | |
assertThat(true, is(matched(regex, "test.GIF"))); | |
assertThat(true, is(matched(regex, "test.JPG"))); | |
assertThat(true, is(matched(regex, "test.BMP"))); | |
assertThat(true, is(matched(regex, "test.PNG"))); | |
assertThat(true, is(matched(regex, "testA.PNG"))); | |
assertThat(false, is(matched(regex, "test a.gif"))); | |
assertThat(false, is(matched(regex, "test a.jpg"))); | |
} | |
@Test | |
public void 비밀번호체크() { | |
String regex = "^[a-zA-Z0-9~!@#$%^&*()]{8,16}"; | |
assertThat(true, is(matched(regex, "adfadf1212"))); | |
assertThat(true, is(matched(regex, "a23d3f31"))); | |
assertThat(true, is(matched(regex, "rbdn200111111111"))); | |
assertThat(true, is(matched(regex, "aaaaaaaaaa212121"))); | |
assertThat(true, is(matched(regex, "aBdAf1234"))); | |
assertThat(true, is(matched(regex, "abc~!@#$234"))); | |
assertThat(true, is(matched(regex, "~!@#$%^&*()"))); | |
assertThat(true, is(matched(regex, "1asfdA~!@af^&*()"))); | |
assertThat(false, is(matched(regex, "a"))); | |
assertThat(false, is(matched(regex, "a121212"))); | |
assertThat(false, is(matched(regex, "a121212a121212a121212"))); | |
} | |
@Test | |
public void 비밀번호체크2() { | |
String regex = "^([a-zA-Z]+[0-9]+[~!@#$%^&*()]+)"; | |
assertThat(true, is(matched(regex, "a0@"))); | |
assertThat(false, is(matched(regex, "a@"))); | |
assertThat(false, is(matched(regex, "@1"))); | |
} | |
/** | |
* <pre> | |
* matched | |
* | |
* <pre> | |
* @param regex | |
* @param inputTxt | |
* @return | |
*/ | |
private boolean matched(String regex, String inputTxt) { | |
return Pattern.matches(regex, inputTxt); | |
} | |
} |
'프로그래밍 > JAVA' 카테고리의 다른 글
[JSON] Array 형태의 JSON String을 Java의 ArrayList generic형태로 변환하기 (0) | 2016.01.08 |
---|---|
Bing Translator API 사용하기 (0) | 2015.12.16 |
Java 이전 버전 다운로드 URL (0) | 2015.09.10 |
[JAVA] 8. 연산자 (0) | 2015.04.21 |
[JAVA] 7. 배열 (0) | 2015.01.07 |