Here is a basic regex-based lexer, very versatile
If the text in the richedit is very long this can be easily adapted to manage the last added line only instead of the whole text
#include <EditConstants.au3>
#include <Color.au3>
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>
Global $Form1 = GUICreate("Form1", 615, 437, 192, 124)
;Global $Edit1 = GUICtrlCreateEdit("", 32, 32, 561, 377)
Global $Edit1 = _GUICtrlRichEdit_Create($Form1, "", 32, 32, 561, 377, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_AppendText($Edit1, "WARNING - The test ran unsuccessfully!" & @CRLF)
_GUICtrlRichEdit_AppendText($Edit1, "PASS - The test ran successfully 2!" & @CRLF)
_GUICtrlRichEdit_AppendText($Edit1, "WARNING - The test ran unsuccessfully again!" & @CRLF)
_colors($Edit1)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _colors($hRichEdit)
Local $red = 0x8888FF, $green = 0x00d65c ; 0xBBGGRR
Local $matchstart, $matchlen, $offset = 1
Local $txt = _GUICtrlRichEdit_GetText($hRichEdit), $len = StringLen($txt)
_GUICtrlRichEdit_PauseRedraw($hRichEdit)
While $offset < $len
$res = StringRegExp($txt, '(?|WARNING|PASS)', 1, $offset)
$offset = @extended
If not IsArray($res) Then Exitloop
$match = $res[0]
$matchlen = StringLen($match)
$matchend = $offset-1
$matchstart = $matchend-$matchlen
_GUICtrlRichEdit_SetSel($hRichEdit, $matchstart, $matchend)
Switch $match
Case "WARNING"
_GUICtrlRichEdit_SetCharBkColor($hRichEdit, $red)
Case "PASS"
_GUICtrlRichEdit_SetCharBkColor($hRichEdit, $green)
EndSwitch
Wend
_GUICtrlRichEdit_SetSel($hRichEdit, -1, -1)
_GUICtrlRichEdit_ResumeRedraw($hRichEdit)
EndFunc