#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?<=明治|大正|昭和|平成)[二三四五六七八]?[一十]?[元一二三四五六七八九十〇](?=年)"
Local $sString = "平成元年" & @CRLF & _
"平成一年" & @CRLF & _
"平成十年" & @CRLF & _
"平成十年" & @CRLF & _
"平成一〇年" & @CRLF & _
"平成十一年" & @CRLF & _
"平成三十年" & @CRLF & _
"平成三〇年" & @CRLF & _
"" & @CRLF & _
"大正十一年" & @CRLF & _
"明治十一年" & @CRLF & _
"昭和十一年"
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