# Function Reference

# _GUICtrlRichEdit_FindTextInRange

Search for a text in a range of inter-character positions

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_FindTextInRange ( $hWnd, $sText [, $iStart = 0 [, $iEnd = -1 [, $bMatchCase = False [, $bWholeWord = False [, $iBehavior = 0]]]]] )

## Parameters

$hWnd | Handle to the control
$sText | Text to find
$iStart | [optional] Starting inter-character position of search Default: beginning of control
$iEnd | [optional] Ending inter-character position of search Default: end of control
$bMatchCase | [optional] Search is case-sensitive Default: case-insensitive
$bWholeWord | [optional] Search only for text as a whole word Default: partial or full word
$iBehavior | [optional] Any BitOR combination of $FR_MATCHALEFHAMZA, $FR_MATCHDIAC and $FR_MATCHKASHIDA Default: 0

## Return Value

Success: | an $Array[2] containing values: If target string found, range of inter-character positions containing the matching text, e.g. [45, 52] If not found, [-1, -1]
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $sText = "" 103 - $iStart is neither a positive number nor zero nor -1 104 - $iEnd is neither a positive number nor zero nor -1 105 - $bMatchCase must be True or False 106 - $bWholeWord must be True or False 1071 - $iBehavior is not a number 1072 - $iBehavior is invalid

## Remarks

The inter-character position at the beginning of the control is 0.
The default character range, 0 to -1, searches the whole text downwwards.
Setting $iEnd to -1 searches down to the end of the control
Setting $iStart to -1 searches up to the start of the control

## Related

_GUICtrlRichEdit_FindText

## See Also

Search EM_FINDTEXTEX in MSDN Library.

## Example

    #include <GUIConstantsEx.au3>
    #include <GuiRichEdit.au3>
    #include <WindowsStylesConstants.au3>

    Global $g_idLbl_Msg

    Example()

    Func Example()
        Local $hGui, $iMsg, $aiPos, $hRichEdit
        $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
        $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
                BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
        $g_idLbl_Msg = GUICtrlCreateLabel("", 10, 235, 300, 60)
        GUISetState(@SW_SHOW)

        _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.")

        $aiPos = _GUICtrlRichEdit_FindTextInRange($hRichEdit, "test", 20, 6)
        Report('"test" found between inter-character positions ' & $aiPos[0] & " and " & $aiPos[1])

        While True
            $iMsg = GUIGetMsg()
            Select
                Case $iMsg = $GUI_EVENT_CLOSE
                    _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                    ; GUIDelete()   ; is OK too
                    Exit
            EndSelect
        WEnd
    EndFunc   ;==>Example

    Func Report($sMsg)
        GUICtrlSetData($g_idLbl_Msg, $sMsg)
    EndFunc   ;==>Report