본문 바로가기

슬기로운생활

울트라에디트(UltraEdit) 정규식 사용

단어 변경하기


울트라 에디트에서는 정규식(Regex)지원해서 더욱 강력한 텍스트 에디터 기능을 제공하고 있다. 예를 들어 te로 시작하고 st로 끝나는 모든 문자를 찾아서 지우고 싶다면 일반 편집기로는 불가능하고 프로그램을 만들어야 한다. 하지만 울트라 에디트에서는 문자를 찾아서 변경할 때 정규식을 지원해 다양한 형식의 문자를 한 번에 교체할 수 있다.



먼저 Ctrl + R 키를 눌러 교체 메뉴를 선택한다. 검색할 대상에 정규식(te+st)을 입력하고 교체할 대상에 교체를 원하는 문자(work)를 입력한다. 하단에 있는 정규식 항목을 체크하고 시작 버튼을 누르면 모든 te로 시작하고 st로 끝나는 단어는 work로 바뀐다.


○ 모든 문장 한 줄로 만들기


좀 더 놀라운 기능을 알아보자. 여러 줄로 되어있는 텍스트 파일을 한 줄로 만들어 보다. 이 것 역시 정규 표현 식으로 쉽게 구현할 수 있다반대 경우도 가능하다. 한 줄로 되어 있는 문장을 특정한 단어나 기호를 기준으로 여러 줄로 나눌 수 있다




동일하게  Ctrl + R 키를 눌러 교체 메뉴를 선택한다. 검색할 대상에 정규식(^p)을 입력하고 교체할 대상에 교체를 원하는 문자(공백)을 입력한다. 하단에 있는 정규식 항목을 체크하고 시작 버튼을 누르면 모든 문장이 한 줄로 표시된다.


*참고 : https://www.ultraedit.com/support/tutorials-power-tips/ultraedit/regular-expressions.html



UltraEdit / Unix regular expressions examples


Simple string matching

Simple string matching is probably the most basic form of regular expressions but can allow you to quickly exploit different patterns so that you can search for more than one string at a time rather than doing multiple Find operations.

UltraEdit legacy regex:

Find what: m?n
Matches: "man" and "men" but not "moon" 

Find what: t*t
Matches: "test", "tonight" and "tea time" (the "tea t" portion) but not "tea 
time" (newline between "tea " and "time").

Find what: Te+st
Matches: "test", "teest", "teeeest", etc. but does not match "tst"

Unix regex:

Find what: m.n
Matches: "man" and "men" but not "moon"

Find what: t.*t
Matches: "test", "tonight" and "tea time" (the "tea t" portion) but not "tea
time" (newline between "tea " and "time").

Find what: Te+st
Matches: "test", "teest", "teeeest", etc. but does not match "tst"


반응형