사용자:콩가루/awb/치환

위키백과, 우리 모두의 백과사전.
  • 꼭 필요하다고 생각되는 부분만 번역합니다. 추가 번역이 필요하시면 연락주세요.

일반[편집]

Show example screen shot

Find and replace

  • Ignore external/Interwiki links, images, nowiki, math, <!-- --> – If checked AWB will mask these items so that find & replace entries are not applied to them. Calls HideText.Hide() – see Hide documentation.
  • Ignore templates, refs, link targets, and headings – If checked AWB will mask the items above plus these items and quotes between quotation marks (all the most common ones) so that find & replace entries are not applied to them. Calls HideText.HideMore() – see HideMore documentation.
  • Add replacements to edit summary – If checked AWB will add the replacements made to the edit summary - up to a certain length of text (255 bytes). Take care with this when working with wikimarkup characters that would make the edit summary invalid.
  • Search: – Enter a search criterion in search box.
  • Go – Will search for what was entered in the search box.
  • Clear – Clears all the rules.
  • Done – Exit Find and replace
Find – 찾을 단어. 아래 키워드 사용 가능(정규식 사용 안 하면)
Replace with – 교체될 단어 Special fields include:
$1, $2 etc. "regex"를 체크해서 정규 표현식을 사용할 경우
각각의 쌍은 괄호에 싸인 부분입니다. 만약 (123)4(5)67을 찾는다면, $1은 123, $2는 5인거
AWB 키워드는 아래와 같은 게 있음. 치환됨. Advanced 모드에서도 동일
keyword value for
Albert Einstein
value for
Wikipedia:AutoWikiBrowser/Find and replace
%%key%%
(human name sort key)
Einstein, Albert Replace, Autowikibrowser/Find And
%%title%% Albert Einstein (제목) Wikipedia:AutoWikiBrowser/Find and replace
%%fullpagename%% Albert Einstein (페이지 전체제목) Wikipedia:AutoWikiBrowser/Find and replace
%%pagename%% Albert Einstein (페이지명) AutoWikiBrowser/Find and replace
%%subpagename%% (하위 페이지명) Albert Einstein Find and replace
%%basepagename%% Albert Einstein AutoWikiBrowser
%%namespace%% Wikipedia
%%server%% http://en.wikipedia.org http://en.wikipedia.org
%%servername%% (서버이름) en.wikipedia.org en.wikipedia.org
%%scriptpath%% /w /w
To match on a newline use \n. From AWB 틀:Awbsvn this is supported for standard and regular expression searches. March 2014년 기준, unless you have compiled AWB yourself \n matches newlines only when using regular expressions.
Case Sensitive – 체크하면 대소문자 구별
Regex – 정규 표현식 사용 regular expression.
Multiline – If checked, this indicates to AWB that the regex characters "^" and "$" ought to match at the beginning and the end of lines respectively, not just the beginning and end of the entire page. In some programming contexts this is referred to as treating the page as a multiline string.
Singleline – If checked, this indicates to AWB that the regex character "." matches every character. Instead of every character except "\n". In some programming contexts this is referred to as treating the page as a singleline string. The "Multiline" and "Singleline" options separately affect how different special characters are interpreted and are not mutually exclusive.
Minor – If checked, AWB will mark this rule as minor. By using "Skip if: only minor replacement made" AWB will skip the article if the only F&R rules which made a replacement were minor ones. By "replacement made" it means that the rule matched. It does not mean that a change was made. The replacement may be with the exact same text as was matched. In such case a replacement was made, but the replacement was exactly the same text as was already present in the article. Currently, F&R rules marked as minor are not acted upon when the command to re-parse the page is made (F5 in the edit box, or from the edit box context menu).
After fixes – 체크하면, 다른 규칙을 모두 적용한 뒤에 치환함. Otherwise It will apply this rule before all other rules.
Enabled – 이게 체크되어 있어야 치환함. If checked indicates that this rule is active. If not checked then this rule will be ignored by AWB.

정규 표현식 강좌[편집]

메뉴 자체는 쉬움. 다만 정규표현식을 활용해야만 강력한 도구로 쓸 수 있음. 이에 따라 정규 표현식 미니 강좌를 적겠음. 일단 정규 표현식에서 표를 가져옴.


문자 클래스, "["와 "]" 사이에 포함된 문자 집합 외부에서는 12개의 문자가, 내부에서는 오직 4개의 문자("\", "^", "-", "]", 자바닷넷은 "["를 포함)만 특수문자를 의미한다.

기능 설명
. 문자 1개의 문자와 일치한다. 단일행 모드에서는 새줄 문자를 제외한다.
\ 이스케이프 특수 문자를 식에 문자 자체로 포함한다.
¦ 선택 여러 식 중에서 하나를 선택한다. 예를 들어, "abc¦adc"는 abc와 adc 문자열을 모두 포함한다.
^ 부정 문자 클래스 안의 문자를 제외한 나머지를 선택한다. 예를 들면 [^abc]d는 ad, bd, cd는 포함하지 않고 ed, fd 등을 포함한다. [^a-z]는 알파벳 소문자로 시작하지 않는 모든 문자를 의미한다.
[] 문자 클래스 "["과 "]" 사이의 문자 중 하나를 선택한다. "¦"를 여러 개 쓴 것과 같은 의미이다. 예를 들면 [abc]d는 ad, bd, cd를 뜻한다. 또한, "-" 기호와 함께 쓰면 범위를 지정할 수 있다. "[a-z]"는 a부터 z까지 중 하나, "[1-9]"는 1부터 9까지 중의 하나를 의미한다.
() 하위식 여러 식을 하나로 묶을 수 있다. "abc¦adc"와 "a(b¦d)c"는 같은 의미를 가진다.
* 0회 이상 0개 이상의 문자를 포함한다. "a*b"는 "b", "ab", "aab", "aaab"를 포함한다.
+ 1회 이상 "a+b"는 "ab", "aab", "aaab"를 포함하지만 "b"는 포함하지 않는다.
? 0 또는 1회 "a?b"는 "b", "ab"를 포함한다.
{m} m회 "a{3}b"는 "aaab"만 포함한다.
{m,} m회 이상 "a{2,}b"는 "aab", "aaab", "aaaab"를 포함한다. "ab"는 포함되지 않는다.
{m, n} m회 이상 n회 이하 "a{1,3}b"는 "ab", "aab", "aaab"를 포함하지만, "b"나 "aaaab"는 포함하지 않는다.


이에 따라 "(fa|mo|b?o)ther"는 "father", "mother", "bother", "other"를 나타낸다.

많은 프로그래밍 언어에서는 이를 확장한 문법을 가지고 있다. 이 중 일반적으로 사용되는 연산자는 다음과 같다.

  • "^", "$" : 각각 문자열이나 행의 처음과 끝을 나타낸다.

주의사항[편집]

  1. 정규 표현식을 쓸 때, \, [,],{,}, .,*는 특수문자 취급임. 이거 모르면 무지 삽질하므로 주의 요망.
  2. 정규 표현식을 쓸 때, 식이 복잡하면 속도가 조금 느림

예제[편집]

날짜 뽑기[편집]

  1. January ([0-9]{1,2}), ([0-9]{4})

이런 식으로 하나하나 Jan, Feb, 등등 하면 됩니다. 다만 이것을 그대로 쓰기엔 문제가 있음. 파일 제목에 들어가 있는 날짜도 멋대로 찾아버림. 그래서 어떻게 해결을 했느냐,

=( |)January ([0-9]{1,2}), ([0-9]{4})

찾으려고 한 것이 인용 틀 내에 있는 날짜임. 인용 틀 내에는 변수가 주어지므로 =가 앞에 있고 뒤에 날짜가 나와야 함. 이제 이 정규식을 해석함

( |) 이게 뭐니?
(A|B)는 A 또는 B. ( |)는 공백이 하나 있거나, 없거나.
([0-9]{1,2}) 쓸때없는 괄호 아닌가
아님. 위에서 말했지만 괄호 첫번째, 괄호 두번째를 $1, $2 식으로 해서 나중에 치환할때 씀. 밑에서 자세히 설명
[0-9] 이건 뭐야?
유니코드 (UTF-8)에서 0,1,2,...,9 순으로 등록됨. 0부터 9까지 찾으라는 이야기. 아래에 유용한 것 더 씀
[A-Z] : 대문자
[a-z] : 소문자
[A-Za-z] : 영문자
[가-힣] : 한글 전체
{1,2} 이건 뭐야?
앞에 있는 [0-9] 글자가 1번 이상 2번 이하로 나오는 경우. 참고로 {4}는 앞에 있는 문자가 4번 나오라는 소리. 참고로 가{4}는 "가가가가"를 찾으라는 거야.

일단 Find에 들어가는 것은 알아봤으니, Replace에 있는 것을 보자.

= $3년 1월 $2일

알죠? 세 번째 괄호의 내용, 두 번째 괄호의 내용

이제 치환 예

= January 3, 2010 이라는 문자열이 있다. 위 정규식을 적용하면 2010년 1월 3일로 바뀜

특수 기능[편집]

\n : 줄 바꾸기