#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?s)\{\{[^{]*?CSM\n.*?(?=\{|$)"
Local $sString = "{{c1: what is horticulture CSM}}" & @CRLF & _
"" & @CRLF & _
"{{c2 : how much is production CSP}}" & @CRLF & _
"" & @CRLF & _
"{{c3: which state rank 1st in horticulture CSP}}" & @CRLF & _
"" & @CRLF & _
"{{c5: how to improve horticulture production CSM}}" & @CRLF & _
"" & @CRLF & _
"{{c6: how much is production of fruits CSP}}" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"out of this above note 6 questions will be formed ( called as cards ) c1, c2. c3 and so on. " & @CRLF & _
"" & @CRLF & _
"here is how my cards will look for C1. card 1: c1" & @CRLF & _
"" & @CRLF & _
"{{c1: ...}}" & @CRLF & _
"" & @CRLF & _
"how much is production CSP" & @CRLF & _
"" & @CRLF & _
"which state rank 1st in horticulture CSP" & @CRLF & _
"" & @CRLF & _
"how to improve horticulture production CSM" & @CRLF & _
"" & @CRLF & _
"how much is production of fruits CSP" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"here is how my card will look for C2 . card 2 : C2" & @CRLF & _
"" & @CRLF & _
"what is horticulture CSM" & @CRLF & _
"" & @CRLF & _
"{{c2 : ... }}" & @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