%REPLACETEXT{ action="..." web="..." from="..." to="..." }%
| Parameter | Description | Default |
|---|---|---|
action="..." |
Replace action: • "" - no action • "replace" - do replace action based on below parameters, return result message, such as: Replaced FOO with BAR in 2 topics in Sandbox web |
"" |
web="..." |
Name of web to search and replace text | (current web) |
topic="..." |
Expert mode: Limit topics by name: A topic with asterisk wildcards, such as Bug-*, or a list of topics separated by comma | (all topics) |
filter="..." |
Expert mode: Limit topics by filtering topic text with a regex filter, optional | (no filter) |
from="..." |
Text to search | (none, required) |
to="..." |
Replacement text | (none, required) |
search="..." |
Expert mode: Use this for more complex replace using regular expression grouping etc; typically supplied via a hidden input field. Use $from to specify the search text entered by the user |
"\b$from\b" |
replace="..." |
Expert mode: Use this for more complex replace using regular expression grouping etc; typically supplied via a hidden input field. Use $to to specify the replacement text entered by the user, use $1, $2, etc to reference captured groups |
"$to" |
dryrun="1" |
Do a dry run, e.g. a search only to simulate the replace action | "0" |
showlist="1" |
Show the list of topics replaced | "0" |
$TWiki::cfg{Plugins}{ReplaceTextPlugin}{AccessGroup} configure setting.
from, to, search, replace parameters, as documented at REPLACETEXT. The search and replace parameters allows for more complex search and replace operations using regular expression grouping.
If you need even more control over search and replace you can write your own search and replace module, such as to sort a list based on the search and replace operation. For this you can clone and modify twiki/lib/TWiki/Plugins/ReplaceTextPlugin/CustomReplace.pm. Specify the name of your module in the $TWiki::cfg{Plugins}{ReplaceTextPlugin}{CustomReplace} configure setting, such as 'TWiki::Plugins::ReplaceTextPlugin::MyReplace'.
Add a function as follows:
replaceText( $web, $topic, $text, $search, $replace ) -> $text
ReplaceTextPlugin.zip in your twiki installation directory. Content: | File: | Description: |
|---|---|
data/TWiki/ReplaceTextPlugin.txt | Plugin topic |
data/TWiki/VarREPLACETEXT.txt | Variable documentation |
lib/TWiki/Plugins/ReplaceTextPlugin.pm | Plugin Perl module |
lib/TWiki/Plugins/ReplaceTextPlugin/Config.spec | Configuration spec file |
lib/TWiki/Plugins/ReplaceTextPlugin/Core.pm | Plugin core module |
lib/TWiki/Plugins/ReplaceTextPlugin/CustomReplace.pm | Template for custom replace module |
| Author: | TWiki:Main.PeterThoeny |
| Copyright: | © 2019-2023 ALPS Plastic. © 2019-2023 TWiki:Main.PeterThoeny © 2019-2023 TWiki:TWiki.TWikiContributor |
| License: | GPL (GNU General Public License |
| Sponsor: | ALPS Plastic |
| Version: | 2023-06-26 |
| 2023-06-30: | TWikibug:Item7864 |
| 2021-04-21: | TWikibug:Item7864 |
| 2019-05-05: | TWikibug:Item7864 |
| 2019-05-04: | TWikibug:Item7864 |
| TWiki Dependency: | $TWiki::Plugins::VERSION 1.2 |
| CPAN Dependencies: | none |
| Other Dependencies: | none |
| Perl Version: | 5.008 |
| Plugin Benchmark |
GoodStyle nn%, FormattedSearch nn%, ReplaceTextPlugin nn% |
| Home: | http://TWiki.org/cgi-bin/view/Plugins/ReplaceTextPlugin |
| Feedback: | http://TWiki.org/cgi-bin/view/Plugins/ReplaceTextPluginDev |
| Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/ReplaceTextPluginAppraisal |
| PackageForm | |
|---|---|
| TopicClassification | PluginPackage |
| TestedOnTWiki | 6.1, 6.0, 5.1, 5.0, 4.3, 4.2, 4.1, 4.0.0 |
| TestedOnOS | OsLinux |
| ShouldRunOnOS | AnyOS |
| InstalledOnTWikiOrg | No |
| DemoUrl | |
| DevelopedInSVN | Yes |
| ModificationPolicy | PleaseFeelFreeToModify |
| RelatedTopics | GlobalReplacePlugin |
| I | Attachment | History | Action | Size | Date | Who | Comment |
|---|---|---|---|---|---|---|---|
| |
ReplaceTextPlugin.md5 | r9 r8 r7 r6 r5 | manage | 0.2 K | 2023-06-30 - 07:44 | PeterThoeny | |
| |
ReplaceTextPlugin.tgz | r9 r8 r7 r6 r5 | manage | 8.5 K | 2023-06-30 - 07:44 | PeterThoeny | |
| |
ReplaceTextPlugin.zip | r9 r8 r7 r6 r5 | manage | 13.1 K | 2023-06-30 - 07:44 | PeterThoeny | |
| |
ReplaceTextPlugin_installer | r1 | manage | 3.6 K | 2023-06-30 - 07:44 | PeterThoeny |