#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "([\[].+?[\]])(:\d+)?"
Local $sString = "India , officially the Republic of India (Hindi: Bharat " & @CRLF & _
"Ga ? arajya), is a country in South Asia. It is the seventh-largest country by area, the second-most populous country, and the most populous democracy in the world. Bounded by the Indian Ocean on the south, the Arabian Sea on the south" & @CRLF & _
"" & @CRLF & _
"asdlfasjdflksd [2]" & @CRLF & _
"slkdjwed[3223][123][jhhjkzu7]" & @CRLF & _
"some references have a page number: [678]:7898[rtzu]" & @CRLF & _
"(lis jkjkh j k lis jkjkh j k ? ten ? ten)hjjh jgj jh g[456]h (jjhhzjhkjjk)" & @CRLF & _
"" & @CRLF & _
"[g][45]:789"
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