반응형
Replacing
Regular Expressions supports tagged expressions
. This is accomplished using (
and )
to surround the text you want tagged
, and then using \1
in the replace string to substitute the first matched text, \2
for the second, etc.
For example:
Text body | Search string | Replace string | Result |
---|---|---|---|
Hi my name is Fred | my name is (.+) | my name is not \1 | Hi my name is not Fred |
The quick brown fox jumped over the fat lazy dog | brown (.+) jumped over the (.+) | brown \2 jumped over the \1 | The quick brown fat jumped over the fox lazy dog |
에디트플러스로 regex로 편히 수정을 하다보면 키워드를 찾은뒤에 가공이 필요할 때가 있다.
예를들자면
안녕하세요 김정은입니다.
안녕하세요 문재인입니다.
안녕하세요 홍준표입니다.
안녕하세요 닐리리아입니다.
이런상태에서 양식만 조금 바꾸고싶을때가 있을때
안녕 김정은이라고해
안녕 문재인이라고해
...
이렇게 바꾸고 싶을때는 냅두고 싶은 검색키워드를 ()로 감싸서 아래 바꿀 말에서 그룹 순서를 적어서 써먹을 수 있다.
주로 데이터 삽입하는 쿼리문 작성하거나 쿼리문 대량으로 수정할때 써먹을수있음
반응형
'IT > regex' 카테고리의 다른 글
대량의 엑셀 데이터 JSON 파싱, HTML 간이 게시판 리스트로 보여주기 (0) | 2018.04.16 |
---|---|
네이트온 채팅 데이터화, 시각화 word cloud (0) | 2018.04.12 |