#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(.*):\s*Bus Number: Departure\s*\nBus code:\s*([^ ]+)\s([^ ]+)\s([^\n]+)[ \t]*(?:\n|$)((?:[^\n]+\n)+)?"
Local $sString = "KPN_Sleeper: Bus Number: Departure " & @CRLF & _
"Bus code: Kpn-866489 KA-01-7233 Bangalore dfdf" & @CRLF & _
"AC Sleeper/56 Seats" & @CRLF & _
"24 Seats booked " & @CRLF & _
"" & @CRLF & _
"SRS: Bus Number: Departure " & @CRLF & _
"Bus code: SRS-5858 KA-31-5985 Bangalore dfdf dfd" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"SAM: Bus Number: Departure " & @CRLF & _
"Bus code: SAM-0077 TN-23-0777 Chennai "
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm