티스토리 뷰

출처: http://notepad-plus.sourceforge.net/uk/regExpList.php
출처에 가면 다양한 예시도 볼 수 있다.

아직까지 한줄 이상에 대한 replace가 가능해 보이지 않는다.

replace에서 알아두면 좋은 부분이 있다.

"찾을단어:" 와 "바꿀 단어" 가 있다.

여기서 "찾을 단어" 에 정규표현식 regular expression 을 넣었는데, 이 찾을 단어의 일부분을 그대로 replace하는 단어로 가져가고 싶을 때가 있다.
이 때는
\1 / \2 / \3  ...
등이 쓰인다.

예를 들면

  찾을 단어: ^\+([. ]*)    // +로 시작하는 line
  바꿀 단어: -\1    // -로 앞을 시작하고, 찾을 단어의 정규표현식중 첫번째 괄호를 그대로 뒤로 가져온다.

이렇게 된다.


In a regular expression, special characters interpreted are:

. Matches any character
( This marks the start of a region for tagging a match; so what's inside ( ) you can use in "replace with" using \1, \2 etc.
) This marks the end of a tagged region.
\n Where n is 1 through 9 refers to the first through ninth tagged region when replacing. For example, if the search string was Fred([1-9])XXX and the replace string was Sam\1YYY , when applied to Fred2XXX this would generate Sam2YYY .
\< This matches the start of a word using Scintilla's definitions of words.
\> This matches the end of a word using Scintilla's definition of words.
\x This allows you to use a character x that would otherwise have a special meaning. For example, \[ would be interpreted as [ and not as the start of a character set.
[...] This indicates a set of characters, for example, [abc] means any of the characters a, b or c. You can also use ranges, for example [a-z] for any lower case character.
[^...] The complement of the characters in the set. For example, [^A-Za-z] means any character except an alphabetic character.
^ This matches the start of a line (unless used inside a set, see above).
$ This matches the end of a line.
* This matches 0 or more times. For example, Sa*m matches Sm , Sam , Saam , Saaam and so on.
+ This matches 1 or more times. For example, Sa+m matches Sam , Saam , Saaam and so on.

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함