Global Replace Plugin
The Global Replace Plugin is designed to:
- Search through topics with user supplied criteria
- Find strings within the topics found
- Provide a mechanism to pick and choose which hits will be replaced
- Replace the hit with a user supplied expressions
Please go to
GlobalSearchAndReplace to perform a global replace operation.
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
Examples
Example 1: Changing a string
- Click Edit from a page
- Copy the string you want to change to the "Replace search string" field. This is the field you want to replace.
- Select web and a search string ( Sandbox,
TestTopic
)
- Replace any other non-numeric and non-alphabetic
[character]
with [\character]
, e.g. [}]
with [\}]
. This applies to "Replace search string" field only.
- E.g. \%EDITCELL\{checkbox, 3, Input data exchange, ... \}\%
- Copy-paste the string to the "Replace string" field and modify it as you choose
- Press the "Search"-button and verify that the replaced and replacing strings are as expected
- Set all the checkboxes of the strings you want to replace. You can also select "Set all"
- Click "Replace all check-marked hits"
Example 2: Inserting a line under another line
- Follow the previous example to the point where "Replace search string" is inserted
- 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 by [$x]
, where [x]
is a number 1-9
.
- E.g. We want to replace a line which ends to a string
[Shutdown}% |]
. "Replace search string": Shutdown\}\% \|(\n)
and "Replace string": Shutdown}% |$1Something$1asdf$1
- Note: Using this trick you can also insert a line before another line, by writing:
- E.g. 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
- E.g. 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 locks, it writes over locked topics
- This Plugin is potentially dangerous. Security measures:
- The operations of this Plugin is restricted to the group which can edit the DefaultPreferences (usually AdminGroup)
- For public sites, it is recommended to enable this Plugin only for the short time when needed (it is installed if the following variable shows "installed": %GLOBALREPLACE{func="check"}%)
- This Plugin has been tested. However, it does not have ANY WARRANTY, does not even have the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
Plugin Installation Instructions
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".
If you have any problems, or if the extension isn't available in
configure
, then you can still install manually from the command-line. See
http://foswiki.org/Support/ManuallyInstallingExtensions for more help.
Plugin Info