Web browsers typically support some basic find functionality. However, I needed in wiki Edit mode support for some more powerful find&replace functionality without going full wysiwyg.
The enclosed javascript does just that: it adds a Find&Replace toolbox to the Edit screen supporting global replace functions, regular expressions (with help) and Undo functionality.
--DF, Jun 2004
Updated Sep 2005 : toolbox is now fixed below the edit textarea, instead of a dropdown menu --DF

Screenshot #

BrushedScreenshotReplaceToolbar.jpg

Usage#

  • You can perform global find and replace operations on the edit textarea.
  • (Jul 2006) find&replace is now also possible on a selection of your text; these are the steps to follow ...
    • first enter all find and replace parameters (find:, replace:, and the different checkboxes)
    • then, make your text selection
    • finally press Replace, et voila, only the matches inside the selected text are replaced
You can use meta-characters in the Find field:

. any character except newline + one or more times
* zero or more times ? zero or one time
{n} match exact n times {n,m} at least n, at most m times
| pipe: a|b matches a or b - hyphen, match a range of chars
^ beginning of a line $ end of a line
[...] one of the char's of a set [^...] negated character set
\b word boundary \B non word boundary
\d numeral [0-9] \D non numeral [^0-9]
\s single white space \S single non white space
\w [A-Za-z0-9_] \W [^A-Za-z0-9_]
(...) grouping are stored as $1..$9 \. escape a meta char

The Replace field can use $1..$9 as a backreference to parentheses of Find field.


Example:

Find /abc|def/ will match the word 'abc' or the word 'def'
Find /bwiki/b will match the word 'wiki' but not the word 'jspwiki'
Find ^[IVXMDCL]+\. will match any combination of roman numeral char's followed by a period
Find /(-?\d+)(\d{3})/ and replace with $1,$2 to insert commas in large integers.

This is the EditFindAndReplaceHelp page. More info on regular expressions and RegExp Sandbox


Back to BrushedTemplate

Comments & Discussion#

--DF, 26 jun 2004
Added some regexp parameters to better support "^" and "$" metacharacters. Some other bug related to the undoMemory is also fixed.

--DF, Sep 2005
Major refactoring inline with latest update of BrushedTemplate

--DF, Jul 2006
Support Find&Replace on selection of text. Next to (multi-level) UNDO also REDO is supported.

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
jpg
BrushedScreenshotEditFindAndRe... 11.4 kB 1 21-Jun-2004 22:49 DirkFrederickx
jpg
BrushedScreenshotReplaceToolba... 19.9 kB 1 25-Sep-2005 14:10 DirkFrederickx
« This page (revision-10) was last changed on 12-Oct-2007 13:58 by 83.138.0.70