티스토리 뷰
울트라에디터 정규식 표현들입니다.
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 RegExp:
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 RegExp:
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"
Character Sets
A character set is a group of characters bounded by "[" and "]". These may be used to designate specific characters to be matched or ranges (i.e. [aeud], or [a-z]).
UltraEdit RegExp:
Find What: [aeiou]
Matches: every vowel
NOTE: Regular Expressions in UltraEdit are not case-sensitive unless Match Case is selected in the Find dialog.
Find What: [,.^?]
Matches: a literal ",", "." or "?".
Because the "?" is a symbol used in expressions it must be "escaped" for the literal character to be matched rather than interpreted as an expression.
Find What: [0-9a-z]
Matches: any digit or letter
Find What: [~0-9]
Matches: any character except a digit (~ means NOT the following)
UNIX RegExp:
Find What: [aeiou]
Matches: every vowel
Find What: [,\.?]
Matches: a literal ",", "." or "?".
Because the "." is a symbol used in expressions it must be "escaped" for the literal character to be matched rather than interpreted as an expression.
Find What: [0-9a-z]
Matches: any digit or letter
Find What: [^0-9]
Matches: any character except a digit (^ means NOT the following)
OR Expressions
Currently UltraEdit only allows for the specification of two operands for an OR expression. You may search for an expression A or B as follows:
UltraEdit RegExp:
Find What: ^{John^}^{Tom^}
UNIX RegExp:
Find What: (John|Tom)
There should be nothing between the two expressions. You may combine A or B and C or D in the same search as follows:
UltraEdit RegExp:
Find What: ^{John^}^{Tom^} ^{Smith^}^{Jones^}
UNIX RegExp:
Find What: (John|Tom) (Smith|Jone)
This will search for "John" or "Tom" followed by "Smith" or "Jones".
Deleting Blank Lines
With Regular Expressions selected in the Replace dialog this will match the a CR/LF (DOS line terminator) immediately followed by the end of a line (i.e., a blank line) and replace it with nothing, effectively deleting it:
UltraEdit RegExp:
Find What: ^p$
Replace With: (literally nothing)
UNIX RegExp:
Find What: \p$
Replace With: (literally nothing)
Reformatting Text With Tagged Expressions
Example 1:
Tagged expressions may be used to mark various data members so that they may be reorganized, reformatting the data. For example, it might be useful to be able to rearrange:
John Smith, 385 Central Ave., Cincinnati, OH, 45238
into:
45238, Smith, John, 385 Central Ave., Cincinnati, OH
UltraEdit RegExp:
Find What: %^([a-z]+^) ^([a-z]+^), ^(*^), ^(*^), ^(*^), ^([0-9]+^)
Replace With: ^6, ^2, ^1, ^3, ^4, ^5
UNIX RegExp:
Find What: ^([a-z]+) ([a-z]+), (.*), (.*), (.*), ([0-9]+)
Replace With: \6, \2, \1, \3, \4, \5
Example 2:
If you have a web-based registration system it might be useful to rearrange the order data into a format easily used by a database:
name = John Smith
address1 = 385 Central Ave.
address2 =
city = Cincinnati
state = OH
zip = 45238
into:
John Smith, 385 Central Ave.,, Cincinnati, OH, 45238,
This can be done with the following expression:
UltraEdit RegExp:
Find What: name = ^([a-z ]+^)^paddress1 = ^([a-z 0-9.,]+^)^paddress2 = ^([a-z 0-9.,]++^)^pcity = ^([a-z]+^)^pstate = ^([a-z]+^)^pzip = ^([0-9^-]+^)
Replace With:^1, ^2, ^3, ^4, ^5, ^6
UNIX RegExp:
Find What: name = ([a-z ]+)\paddress1 = ([a-z 0-9.,]+)\paddress2 = ([a-z 0-9.,]*)\pcity = ([a-z]+)\pstate = ([a-z]+)\pzip = ([0-9^-]+)
Replace With:\1, \2, \3, \4, \5, \6
'Computer > Tool' 카테고리의 다른 글
[Source Insight] 프로젝트 설정 초기 사용법 (0) | 2015.02.23 |
---|---|
[Google Web Designer] 구글 웹디자이너 HTML5 개발툴 (0) | 2015.02.23 |
[UltraEdit] 울트라에디터 정규식으로 찾기 바꾸기 (0) | 2015.02.22 |
Eclipse Hotkey 단축키 (0) | 2015.02.17 |
Eclipse Text Font 변경 (0) | 2014.09.23 |