replaceAll

replaceAll(match:          String;
           replacement:    String;
           range:          Integer;
           direction:      Integer;
           caseSensitive:  Boolean;
           wholeWord:      Boolean;
           wordStart:      Boolean;
           interpretation: Integer): Integer;

The replaceAll method of the JadeTextEdit class searches for specified text in the text editor and replaces it with the specified replacement text.

This method performs a single undo action, which is a looped find method call followed by a replace method call until the replace action returns a not found result.

The replaceAll method parameters are listed in the following table.

Parameter Description
match Mandatory value, which specifies the text to be located.
replacement The text that replaces instances of text in the receiver matching that specified by the match parameter.
range Range of search. One of FIND_RANGE_ALL (0), FIND_RANGE_CARET (1), or FIND_RANGE_SELECTION (2). The FIND_RANGE_SELECTION (2) can be a stream selection, line selection, or rectangular selection.
direction Direction in which to search. Specify -1 to search backwards towards the top of the text editor, zero (0) or +1 to search forwards towards the bottom of the text editor. The search is always performed starting at the position closest to the top of the text.
caseSensitive If true, finds only text with the matching case. If false (the default), the search is case-insensitive.
wholeWord If true, finds only whole words. If false (the default), finds parts of words that satisfy the search.
wordStart If true, the match must occur at the start of a word (that is, the matched text must be preceded by a non-word character).
interpretation One of the following values, represented by JadeTextEdit class constants.
 
  • FIND_INTERP_NONE (0), to search for text as is

 
  • FIND_INTERP_POSIXREGEXPR (3), to search for a POSIX regular expression

 
  • FIND_INTERP_REGEXPR (2), to search for a regular expression

 
  • FIND_INTERP_UNSLASH (1), to search for backslash control characters

For details about interpretation, see the find method.

The caret is positioned as close as possible to its apparent original location.

The replaceAll method returns the number of replacements that were made. If the selection is empty and FIND_RANGE_SELECTION is specified, it returns -2.

The code fragment in the following example shows the use of the replaceAll method to replace all occurrences of "fred" with "harry" between the caret and the end of the text.

count := self.theJadeTextEdit.replaceAll("fred", "harry",1 /*range*/,
            0/*direction*/
            false/*caseSensitive*/, 
            false/*wholeWord*/,
            false/*wordStart*/,
            0 /*interpretation*/ );
if count < 1 then
    app.msgBox("No matches","Replace text",0);
endif;