on
replaceAll (?i)
replaceAll (?i)
반응형
프로젝트를 보던 중
replaceAll 를 사용할 때 (?i)가 적혀있는 것을 보았다... 무슨 뜻일까
replaceFirst() / replaceAll() 메소드(함수)로 문자열을 치환할 때, 대소문자 구분없이 바꾸려면
정규식의 앞 부분에 (?i) 라는 옵션을 넣어주면 됩니다. 물음표+소문자i(아이)입니다.
// 정규표현식으로 제거
String.replaceAll("<(/)?([a-zA-Z]*)(\\s[a-zA-Z]*=[^>]*)?(\\s)*(/)?>","");
// 한줄로 할려면 아래 추가
String.replaceAll("("\r|
| ","");
=>
.replaceAll("<(/)?([a-zA-Z]*)(\\s[a-zA-Z]*=[^>]*)?(\\s)*(/)?>","").replaceAll("\r|
| ","")
출처: https://kooremo.tistory.com/entry/자바-정규식으로-html태그-제거 [자바블로그]
[참조]
바로 아래 사이트는 자세히 정리되어 있다.
https://codechacha.com/ko/java-regex/
http://mwultong.blogspot.com/2006/12/java-replace-string-ignore-case-regex.html
https://kooremo.tistory.com/entry/%EC%9E%90%EB%B0%94-%EC%A0%95%EA%B7%9C%EC%8B%9D%EC%9C%BC%EB%A1%9C-html%ED%83%9C%EA%B7%B8-%EC%A0%9C%EA%B1%B0
반응형
from http://action713.tistory.com/1636 by ccl(A) rewrite - 2021-12-01 10:02:08