SID-01911: Global Replace Plugin Search for TWiki Link Code
| Status: |
Answered |
TWiki version: |
|
Perl version: |
5.10.1 |
| Category: |
GlobalReplacePlugin |
Server OS: |
Turnkey Linux 12.1 |
Last update: |
11 years ago |
In trying to search for TWiki link code (such as [[) and replace it with HTML link code (such as <a href="), Global Replace does not behave as for other searches / replaces.
With the following specified:
Topic Search String: ?.* (to search all topics in the web)
Replace Search String: \[[ (to locate all instances of "[[" in each searched topic)
The following standout odd results occur:
1. Only the first instance of "[[" in each topic is returned; none of the other instances is returned. (For my searches, these are
WebHome links.)
2. Instead of returning "[[" matches, "[[WebHome" instances are returned.
3. The returned "[[WebHome" match is actually duplicated. Which does NOT occur in the topic. The core of a typical returned topic is as below:
Text Found: [[WebHome[[WebHome (Where the first is red-texted for replacement.)
Replace With: <a href="[[WebHome
Does anyone know the reason for this?
Thanks,
--
Patrick Townsend-Wells - 2014-04-18
Discussion and Answer
The
[ is a special character that starts a character set. You need to escape special characters if you want to scan literally. So, search for
\[\[. If you want to scan for the full link, write
\[\[(.*?)\]\], and in the replace part use
$1 to get the topic name.
See regular expression presentation at
TWikiPresentation2013x03x07
--
Peter Thoeny - 2014-04-20
Fantastic Peter.
Thanks,
The Odd One
--
Patrick Townsend-Wells - 2014-04-21
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.