find

find(text:    String;           (JadeRichText)
     start:   Integer;
     finish:  Integer;
     options: Integer): Integer;

find(match:          String;    (JadeTextEdit)
     range:          Integer;
     direction:      Integer;
     caseSensitive:  Boolean;
     wholeWord:      Boolean;
     wordStart:      Boolean;
     interpretation: Integer): Integer;

The find method returns the character position at which the text was found. If no match was found, this method returns -1.

The find method of the JadeRichText class searches for text within the contents of the control. The find method parameters for rich text controls are listed in the following table.

Parameter Description
text Text to be located.
start Start of the search range, as a character index into the text or specified as Find_BeginningOfText.
finish End of the search range, as a character index into the text or specified as Find_EndOfText.
options One or more of the following values, separated by the plus symbol (+).
 
  • Find_MatchCase, which finds only text with the matching case; otherwise search is case-insensitive.

 
  • Find_WholeWord, which finds only whole words; otherwise parts of words satisfy the search.

 
  • Find_SearchBack, which searches backwards through the text; otherwise the search direction is forward to the end of the text.

 
  • Find_Default, when no other option is specified. You cannot use this value in any combination with any other option value.

The find method of the JadeTextEdit class searches for text within the contents of the text editor. The find method parameters for text edit controls are listed in the following table.

Parameter Description
match Mandatory value, which specifies the text to be located.
range Range of search. One of FIND_RANGE_ALL (0), FIND_RANGE_CARET (1), or FIND_RANGE_SELECTION (2).
direction Direction in which to search. Specify -1 to search backwards towards the top of the text, zero (0) or +1 to search forwards towards the bottom of the text.
caseSensitive If true, finds only text with the matching case. If false, the search is case-insensitive.
wholeWord If true, finds only whole words. If false, 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 (the default value)

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

    Same as FIND_INTERP_REGEXPR except that the \ and \ sequences become more POSIX-compatible unslashed ( and ) sequences.

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

    The search is performed using the match text a "regular expression". For a list of characters that have special meaning within a regular expression, see the following table.

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

    Before the search begins, the match text has the following backslash escape sequences replaced by the appropriate single character: \a (bell), \b (backspace), \f (form feed), \n (line feed), \r (carriage return), \t (tab), \v (vertical feed), \\ (backslash), \OOO (OOO is three octal digits), \xHH (HH is two hexadecimal digits). A backslash preceding an unrecognized escape character is discarded.

For JadeTextEdit controls, the matching text is selected in the text editor and the caret is positioned at the end of the matched text (that is, the selection).

Characters that have special meaning within a regular expression for interpretation represented by the JadeTextEdit class FIND_INTERP_REGEXPR constant are listed in the following table.

Character Description
. Matches any character.
\( Marks the start of a region for tagging a match.
\) Marks the end of a tagged region.
\n The n value in the range 1 through 9 refers to the first through ninth tagged region when replacing. For example, if the search string is Fred\([1-9]\)XXX and the replace string is Sam\1YYY, when applied to Fred2XXX, this generates Sam2YYY.
\< Matches the start of a word using Scintilla's definitions of words.
\> Matches the end of a word using Scintilla's definition of words.
\x Enables you to use a character x that would otherwise have a special meaning. For example, \[ is interpreted as [ and not as the start of a character set, and \\ means a single backslash character.
[...] Indicates a set of characters; for example, [abc] means any of the characters a, b, or c. You can also use ranges; for example, [a-z] for any lowercase character.
[^...] Complement of the characters in the set. For example, [^A-Za-z] means any character except an alpha character.
^ Matches the start of a line (unless used inside a set, as stated for [^...] in the previous row).
$ Matches the end of a line.
* Matches zero or more times. For example, Sa*m matches Sm, Sam, Saam, Saaam, and so on.
+ Matches one or more times. For example, Sa+m matches Sam, Saam, Saaam, and so on.

A regular expression can also contain the escape sequences listed for FIND_INTERP_UNSLASH, except for \xHH. The find method returns -1 if the match text is an invalid regular expression (for example, an unbalanced [).