admin_tool2Add my vote for this tag automation2Add my vote for this tag editing2Add my vote for this tag findability1Add my vote for this tag productivity2Add my vote for this tag search3Add my vote for this tag create new tag
, view all tags

Global Replace Plugin

Global search and replace functionality across all topics in a web


The Global Replace Plugin is designed to:

  1. Search through topics with user supplied criteria
  2. Find strings within the topics found
  3. Provide a mechanism to pick and choose which hits will be replaced
  4. Replace the hit with a user supplied expressions

Please go to GlobalSearchAndReplace to perform a global replace operation.


Example 1: Changing a string

  1. Click Raw Edit from a page.
  2. Copy the string you want to change into the clipboard.
  3. Go to GlobalSearchAndReplace and paste the string into the "Replace search string" field. This is the field you want to replace.
  4. Select web and a search string.
  5. Escape any non-numeric and non-alphabetic character with a backslash, such as } with \}. This applies to the "Replace search string" field only.
    • Example: \%EDITCELL\{checkbox, 3, Input data exchange, ... \}\%
  6. Copy-paste the string to the "Replace string" field and modify it as needed.
  7. Press the "Search"-button and verify that the replaced and replacing strings are as expected.
  8. Set all the checkboxes of the strings you want to replace. You can also select "Set all".
  9. Click "Replace all check-marked hits".

Example 2: Inserting a line below another line

  1. Follow the previous example to the point where "Replace search string" is inserted.
  2. Use (\n) in the "Replace search string", at the end of the line. This will be stored for use in the "Replace string". You can reference it with $n, where n is a number 0 to 9.
    • Example: We want to replace a line which ends to a string Shutdown}% |.
      "Replace search string": Shutdown\}\% \|(\n) and "Replace string": Shutdown}% |$1Something$foo-bar$1

Note: Using this trick you can also insert a line before another line.

  • Example: We want to insert a line before another line, which begins with a string | *Keywords:* |.
    "Replace search string": \| \*Keywords\:\* \|(.*?)(\n) and "Replace string": Something $2| *Keywords: |$1$2
  • Example: We want to replace a line which begins with a string | *Keywords:* | and ends with or contains the string Interrupt}%.
    "Replace search string": \| \*Keywords\:\* \|(.*?)Interrupt\}\%(.*?)(\n) and "Replace string": Something $3| *Keywords: |$1Interrupt}%$2$3

Known Issues

  • This plugin ignores locked topics, it writes over locked topics.
  • This plugin is potentially dangerous. Security measures:
    1. The operations of this plugin is restricted to the group which can edit the TWikiPreferences (usually TWikiAdminGroup).
    2. For public sites, it is recommended to enable this plugin only for the short time when needed (it is enabled if the following variable shows "installed": %GLOBALREPLACE{func="check"}%).
  • This plugin has been tested. However, operator errors can be done quite easily, especially if regular expressions are not well understood. This plugin does not have ANY WARRANTY, does not even have the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Plugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %GLOBALREPLACEPLUGIN_SHORTDESCRIPTION%

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Global search and replace functionality across all topics in a web

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

Plugin Installation Instructions

Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.

  • For an automated installation, run the configure script and follow "Find More Extensions" in the in the Extensions section.

  • Or, follow these manual installation steps:
    • Download the ZIP file from the Plugins home (see below).
    • Unzip GlobalReplacePlugin.zip in your twiki installation directory. Content:
      File: Description:
      data/TWiki/GlobalReplacePlugin.txt Plugin topic
      data/TWiki/GlobalSearchAndReplace.txt Search replace form topic
      data/TWiki/GlobalSearchAndReplaceHelp.txt Help topic
      data/TWiki/GlobalSearchAndReplaceTopics.txt Replace result topic
      lib/TWiki/Plugins/GlobalReplacePlugin.pm Plugin Perl module
      pub/TWiki/Plugins/GlobalSearchAndReplaceHelp/gsr.png Screenshot
    • Set the ownership of the extracted directories and files to the webserver user.
    • Make sure the dependencies listed in the table below are resolved. None

  • Plugin configuration and testing:
    • Run the configure script, enable the plugin in the Plugins section
    • Plugin is installed and enabled properly if the following variable shows "installed": %GLOBALREPLACE{func="check"}%
    • Test if the installation was successful: Visit GlobalSearchAndReplace to try it out.
    • After each use it is recommended to disable this plugin in the {Plugins} section of configure.

Plugin Info

Plugin Author: TWiki:Main.PaulineCheung, TWiki:Main.PeterThoeny
Copyright: © 2004-2006 Wind River
© 2007-2015 Peter Thoeny, TWiki.org
© 2007-2015 TWiki:Main.TWikiContributors
License: GPL (GNU General Public License)
Plugin Version: 2015-10-16
Change History:  
2015-10-16: TWikibug:Item7568: Support \t, \r, \n in replace string; remember selected web in global search and replace form -- TWiki:Main.PeterThoeny
2012-09-08: TWikibug:Item6837: Doc enhancements -- TWiki:Main.PeterThoeny
2011-12-19: TWikibug:Item6799: Small doc fixes -- TWiki:Main.PeterThoeny
2011-08-02: TWikibug:Item6725: Change global package variables from "use vars" to "our" -- TWiki:Main.PeterThoeny
2011-01-22: TWikibug:Item6638: Many doc improvements; changing TWIKIWEB to SYSTEMWEB -- TWiki:Main.PeterThoeny
05 Oct 2008: TWiki:Main/PeterThoeny: Selectable web; TWiki 4.x compatible
31 Oct 2005: TWiki:Main.MikkoLaakso: Added some examples, tested on W2K.
03 Nov 2004: TWiki:Main/PeterThoeny: Added $topic to replace string
16 Mar 2004: Fixed bug where topics with underlines did not get handled properly
07 Feb 2004: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.0
CPAN Dependencies: none
Other Dependencies: TWiki:Plugins/SpreadSheetPlugin
Perl Version: 5.005
TWiki:Plugins/Benchmark: GoodStyle 99%, FormattedSearch 99%, GlobalReplacePlugin 99%
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/GlobalReplacePlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/GlobalReplacePluginDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/GlobalReplacePluginAppraisal

Related Topics: GlobalSearchAndReplace, GlobalSearchAndReplaceHelp, GlobalSearchAndReplaceTopics, TWikiPlugins, DeveloperDocumentationCategory, AdminDocumentationCategory, TWikiPreferences

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatmd5 GlobalReplacePlugin.md5 r9 r8 r7 r6 r5 manage 0.2 K 2015-10-17 - 02:48 PeterThoeny  
Compressed Zip archivetgz GlobalReplacePlugin.tgz r9 r8 r7 r6 r5 manage 89.4 K 2015-10-17 - 02:48 PeterThoeny  
Compressed Zip archivezip GlobalReplacePlugin.zip r12 r11 r10 r9 r8 manage 92.8 K 2015-10-17 - 02:48 PeterThoeny  
Unknown file formatEXT GlobalReplacePlugin_installer r4 r3 r2 r1 manage 3.6 K 2015-10-17 - 02:48 PeterThoeny  
Edit | Attach | Watch | Print version | History: r18 < r17 < r16 < r15 < r14 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r18 - 2015-10-17 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2016 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.