#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(^\|(\s*[A-Z][A-Z_]*\s*\|)+\s*$)\r?\n(^\|([\s-]+\|)+\s*$)"
Local $sString = "Which SQL query will help you fetch the department ID and department name for departments where the number of employees exceeds 10?" & @CRLF & _
"| EMP_ID | F_NAME | L_NAME | SALARY | DEPT_ID_DEP |" & @CRLF & _
"| --- | --- | --- | --- | --- |" & @CRLF & _
"| 1 | John | Doe | 60000 | 101 |" & @CRLF & _
"| 2 | Jane | Smith | 75000 | 102 |" & @CRLF & _
"| 3 | Emily | Davis | 80000 | 101 |" & @CRLF & _
"| 4 | Michael | Johnson | 65000 | 103 |" & @CRLF & _
"| DEP_ID | DEP_NAME | MANAGER_ID | LOCATION_ID |" & @CRLF & _
"| --- | --- | --- | --- |" & @CRLF & _
"| 101 | IT | 10 | L0001 |" & @CRLF & _
"| 102 | HR | 20 | L0002 |" & @CRLF & _
"| 103 | Finance | 30 | L0003 |" & @CRLF & _
"| 104 | Marketing | 40 | L0004 |"
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