#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?u)(?<![\p{L}0-9])([##][·・ー_0-90-9a-zA-Za-zA-Zぁ-んァ-ン一-龠]{1,24})(?![\p{L}0-9])"
Local $sString = "Hashtag must be started with # character." & @CRLF & _
"Hashtag will be detected by space character and other special characters (!,@,&,*,%,$)." & @CRLF & _
"Example 1: Hello#guys. This is a #test. -> Valid hashtag: #test." & @CRLF & _
"Example 2: Hello#guys. This is a #test!#message. -> Valid hashtag: #test and #message" & @CRLF & _
"Example 3: Hello#guys. This is a #test #message. -> Valid hashtag: #test and #message" & @CRLF & _
"Example 4: Hello#guys. This is a #test#message. -> Valid hashtag: #test" & @CRLF & _
"Example 5: #asdasdasdasdasdasdasdasdasd -> Valid hashtag: none" & @CRLF & _
"Example 6: # -> Valid hashtag: none" & @CRLF & _
"#日本語#asd => Valid hashtag should be #日本語" & @CRLF & _
"#日本語日本語日本語日本語日本語日本語日本語日本語日本語 => Will not a valid hashtag"
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