#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?<!\d)(?<!_)(?<![a-zA-z])string(?!\d)(?!_)(?![a-zA-Z])"
Local $sString = "module mpi_hello_world" & @CRLF & _
" use mpi" & @CRLF & _
" implicit none" & @CRLF & _
"contains" & @CRLF & _
" subroutine hello_world(size, & ! testtest" & @CRLF & _
" & r_ank, &!" & @CRLF & _
" & myhostname &" & @CRLF & _
" & )" & @CRLF & _
"! this is a comment" & @CRLF & _
" ! this also" & @CRLF & _
" integer, intent(in) :: size, rank23, rank_er,ranking, myrank, my2r_ank" & @CRLF & _
" character(len = *), intent(out) :: myhostname" & @CRLF & _
"" & @CRLF & _
" integer :: stat" & @CRLF & _
" " & @CRLF & _
" myhostname = "(no host name)"" & @CRLF & _
"#ifdef __INTEL_COMPILER" & @CRLF & _
" call get_environment_variable("COMPUTERNAME", myhostname)" & @CRLF & _
"#else" & @CRLF & _
" stat = hostnm(myhostname)" & @CRLF & _
"#endif " & @CRLF & _
"" & @CRLF & _
" write(*, *) "Hello world FORTRAN rank:", rank, " size:", size, &" & @CRLF & _
" & "hostname:", trim(myhostname)" & @CRLF & _
" " & @CRLF & _
" end subroutine hello_world" & @CRLF & _
"end module mpi_hello_world" & @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