#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?i)(::\s*\b(function)\b)|\b(function)\b"
Local $sString = "type def" & @CRLF & _
" integer, dimension(:), pointer :: ptr" & @CRLF & _
"end type def" & @CRLF & _
"" & @CRLF & _
"interface set_scalar_field_from_python" & @CRLF & _
" module procedure set_scalar_field_from_python_sp" & @CRLF & _
"" & @CRLF & _
" subroutine set_scalar_field_from_python(function, function_len, dim, &" & @CRLF & _
" nodes, x, y, z, t, result, stat)" & @CRLF & _
" use iso_c_binding, only: c_double, c_int, c_char" & @CRLF & _
" implicit none" & @CRLF & _
" integer(c_int), intent(in), value :: function_len" & @CRLF & _
" character(kind=c_char, len=function_len) :: function" & @CRLF & _
" integer(c_int), intent(in), value :: dim, nodes" & @CRLF & _
" real(c_double), dimension(nodes), intent(in) :: x, y, z" & @CRLF & _
" real(c_double), intent(in), value :: t" & @CRLF & _
" real(c_double), dimension(nodes), intent(out) :: result" & @CRLF & _
" integer(c_int), intent(out) :: stat" & @CRLF & _
" end subroutine set_scalar_field_from_python" & @CRLF & _
"" & @CRLF & _
" ! all these should be in meta.parameter.fortran" & @CRLF & _
" integer function fun_with_func_space( function )" & @CRLF & _
" integer, intent(inout) :: function" & @CRLF & _
" end function fun_with_func_space" & @CRLF & _
"" & @CRLF & _
" subroutine sub_with_func_space( function )" & @CRLF & _
" character(kind=1, len=function_len), intent(inout) :: function" & @CRLF & _
" end subroutine sub_with_func_space" & @CRLF & _
"" & @CRLF & _
" character(kind=1, len=function_len) function fun_with_sub_space( subroutine )" & @CRLF & _
" character(kind=1, len=function_len), intent(inout) :: subroutine" & @CRLF & _
" end function fun_with_sub_space" & @CRLF & _
"" & @CRLF & _
" subroutine sub_with_sub_space( subroutine )" & @CRLF & _
" character(kind=1, len=function_len), intent(inout) :: subroutine" & @CRLF & _
" end subroutine sub_with_sub_space" & @CRLF & _
"" & @CRLF & _
" subroutine normal( arg , simple )" & @CRLF & _
" character(kind=1, len=function_len), intent(inout) :: arg" & @CRLF & _
" integer, intent(inout) :: simple" & @CRLF & _
" end subroutine normal" & @CRLF & _
"" & @CRLF & _
" logical(kind=4) function foo(var) result(val)" & @CRLF & _
" integer, intent(inout) :: var" & @CRLF & _
" end function foo" & @CRLF & _
"" & @CRLF & _
" ! keyword.other.function.fortran" & @CRLF & _
" function name(arg)" & @CRLF & _
" integer :: arg" & @CRLF & _
" end function name" & @CRLF & _
"" & @CRLF & _
" character(len=10) function foo_char() result(val)" & @CRLF & _
" integer :: function" & @CRLF & _
" end function foo_char" & @CRLF & _
"" & @CRLF & _
"end interface set_scalar_field_from_python"
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