维基百科:AutoWikiBrowser/查找和替换

章節: 核心 · 数据库扫描器 · 搜尋和取代 · 規律表達式 · 常规修正(General fixes)
顯示釋例截圖

一般用法 编辑

顯示釋例截圖

搜尋和取代(Find and replace):

  • Ignore external/Interwiki links, images, nowiki, math, <!-- -->(忽略外部鏈結/跨維基鏈接、圖像、nowiki、數學符號、<!-- -->) 如果選取此項,AWB將不會搜尋和取代這些項目。呼叫HideText.Hide()。參見Hide documentation.
  • Ignore templates, refs, link targets, and headings(忽略模板、引用、鏈接目標和標題):如果選取此項,AWB將不會搜尋和取代上一項與此項的項目。呼叫HideText.HideMore() – see HideMore documentation.
  • Add replacements to edit summary(將取代添加到編輯摘要)– 如果選中,則AWB會將所做的取代添加到編輯摘要中,其長度限制為255 bytes。使用Wiki語法字符時要格外小心,這會使編輯摘要無效。
  • Search:(搜尋):在搜尋框輸入搜尋條件。
  • Go(開始):搜尋在搜尋框輸入的內容。
  • Clear(清除):清除所有規則。
  • OK:接受列出的規則並關閉窗口。
  • Cancel(取消):取消任何規則更改並關閉窗口。
 
Find:要找的文字,亦可用以下關鍵字。
Replace with:要取代的文字,特殊fields include:
$1$2等:如搜尋框的文字是規律表達式(regex)且已選取regex就會用搜尋框的值
規律表達式每對括號對應一串字串,如搜尋(123)4(56)78$1對應123;$2對應56
AWB關鍵字會以其值取代,如以下例子。這些關鍵字可用於進階。
關鍵字 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
\n搜尋新行。自AWB Template:Awbsvn起可用於普通及規律表達式搜尋。截至March 2014年 (March 2014-Missing required parameter 1=month!), unless you have compiled AWB yourself \n matches newlines only when using regexes.
Case Sensitive:如選取,就分大小寫。
Regex:如選取,表示搜尋和取代的是規律表達式
Multiline:如選取,表示regex字元「^」和「$」分別符合行首和行尾,而非只是頁首和頁尾。在某些programming contexts這等同視頁面為多行字串。
Singleline:如選取,表示regex字元「.」符合全部字元,包括「\n」。在某些programming contexts這等同視頁面為單行字串。「多行」和「單行」選項分別影響不同特殊字元的解讀方式且不互斥。
Minor:如選取,AWB會視此規則為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 exactly the 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:如選取,AWB will apply this rules after all other rules (general fixes, typos etc.). Otherwise It will apply this rule before all other rules.
Enabled:如選取表示啟用此規則;如無選取則停用。

進階用法 编辑

顯示釋例截圖

該章節將告訴您如何為AWB設置特殊的搜尋和取代條件,可用普通文本或規律表達式來搜尋。

  • Main Menus:主選單
  • New:允許您選擇規則(Rules)或子規則(Subrules)。請參閱下面的規則類型。
  • Rule:各種編輯命令,包括撤消(Undo)、重做(Redo)、剪下(Cut)、複製(Copy)、貼上(Paste)、刪除(Delete)和刷新顏色

  • Types of rules
  • Rule each one of these can be nested so that if the upper most rule is satisfied then AWB will process the next rule below.
Find and replace
In template call
Template parameter:Regular rules, AWB will be process these rules (if enabled) against the text of a page.
  • In Template Call Rule:These rules will only be processed if within a template.
  • Template Parameter Rule:These rules allow you to change template parameter names.
  • Subrule
  • Rule:Same as a regular rule, but only acted upon if the regular rule is acted upon.
  • In Template Call Rule:Same as a regular in template call rule, but only acted upon if the regular in template call rule is acted upon.
  • Template Parameter Rule:Same as a regular template parameter rule, but only acted upon if the regular template parameter rule is acted upon.

  • Name:This allows you to name your rule so that you can recognize it.
  • Enabled:If checked the rule is enabled. If unchecked this rule will be ignored by AWB. Unchecked rules will be highlighted in red in the list of rules.
  • Type
  • Entire text:lets you search with the entire text string.
  • Inside template calls {{..}}:specifies only search within a template. Each template call within the article text will be processed; if there are nested templates, all levels of nested templates will be processed, so for example with {{a|1={{b|2={{c|3=text}}}}}} rules will be processed against {{a|1={{b|2={{c|3=text}}}}}} and {{b|2={{c|3=text}}}} and {{c|3=text}} in turn.
  • Find:In this section you enter your search criteria. If you check the Regular expression box on the bottom of the page, the criteria you enter here will be acted on as it is a regular expression. Otherwise it will be searched as it were regular text case insensitive.
  • Replace with::The criteria you place in this box will be replaced with what was found in the Find section.
  • Regular expression:If checked indicates to AWB that the find criteria is a regular expression.
  • Case sensitive:If checked indicates to AWB that the find criteria is case sensitive.
  • Multiline:If checked, this indicates to AWB that the regex characters "^" and "$" so that they match at the beginning and the end of lines respectively, not just the beginning and end of a whole string.
  • Single line:If checked, this indicates to AWB that the regex character "." matches every character. Instead of every character except "\n".
  • Apply # times:Used for unusual circumstances when it is useful to instruct AWB to iteratively apply the transformation more than once to the same line.
  • If
  • Contains:The page would be checked for the inserted text. If it contains it, AWB would apply the find and replace rule which is defined in the other "Find" tab.
  • Not Contains: The page would be checked for the inserted text. If it doesn't contain it, AWB would apply the find and replace rule which is defined in the other "Find" tab.
  • Regular expression:If checked indicates to AWB that the find criteria is a regular expression.
  • Case sensitive:If checked indicates to AWB that the find criteria is case sensitive.
  • Multiline:If checked, this indicates to AWB that the regex characters "^" and "$" so that they match at the beginning and the end of lines respectively, not just the beginning and end of a whole string.
  • Single line:If checked, this indicates to AWB that the regex character "." matches every character. Instead of every character except "\n".

Template substitution 编辑

When you are editing an article, and you add "subst:" to the beginning of a template name (like this: {{subst:XYZ}}), the template's wikicode is pasted into the wikicode of the article (when you save), rather than merely displayed (transcluded) onto the screen. That is, the template name (and curly brackets) are replaced (substituted) by the contents of the template. This is called substitution.

If you don't know what a template is, see Help:Template. For a more detailed description of substitution, see Wikipedia:Substitution.

The nice thing is, with the "template substitution" feature, AWB will add the "subst:" for you, so you don't have to do it by hand. Just list the names of the templates you want "substituted" in the box.

顯示釋例截圖
  • Templates to substitute:One per line, specify the name of each template you wish to be "substituted". They can be the name of any existing template. Curly brackets and the namespace are optional. For example:
ABC1 (but {{ABC1}}, or Template:ABC1 will also work)
ABC2
ABC3
XYZ
Abracadabra
Alakazam
Turn this rabbit into a ham
(etc.)
When you press "start", AWB will look for each template name (in articles it will be surrounded with curly brackets) and will replace it (and the curlies) with the entire contents of the template (its wikitext). If parameters are included in a template instance it finds, such as {{Alakazam|scooby|doo}}, AWB will run the template and place the resulting output in the article.
Note that if you look in "diff" at the changes, the template will be substituted in there.
  • Ignore external/interwiki links, images, nowiki, math and <!-- -->:If checked AWB will mask these items so that find & replace entries are not applied to them. Calls HideText.Hide() – see Hide documentation.
  • Expand recursively:If template is a redirect, get the subst'd of its target and replaces with that
  • Include comment with template:Includes a comment with the template name - <!-- Template:Test -->
  • Clear:Clears the contents of the "Templates to substitute box"
  • Reset:Sets the Template list back to whatever was entered when ok was last pressed
  • OK:Commits the lines to be used for reset. Closes the window
  • Cancel:Cancel and close the window
  • It is unnecessary to use this feature to substitute the templates listed here, which will be automatically substituted if "General fixes" is turned on.

Order of procedures 编辑

AWB performs these actions in the following order:

  1. Normal Find and Replace (in order listed)
  2. Advanced Find and Replace (per rules specified)
  3. Template Substitution
  4. General Fixes & Typos
  5. Normal Find and Replace rules marked as to occur after General Fixes

保存並恢復搜尋取代格式(Saving and restoring find-and-replace specifications) 编辑

The values you specify in the Find and replace entries are saved when you use the "Save settings" command under the "File" menu (along with other settings). The current entries are erased and the saved ones are restored when you use the "Open settings..." or "Recent settings..." commands.

There is no way to import new Find and replace entries other than directly editing a "settings" file of the kind generated by the "Save settings" command (and then opening it as a settings file). This file is in XML format and so appears as editable text if opened in a text editor.

A list of user contributed settings is available.