#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^.*osf=(\S+?)[;|\s].*$"
Local $sString = "osf=5633d9e768732dc8c7ca1f9a._7iTy0uvL_4eVBf_y_SzRVEeOII; csrftoken=ah8zV0tSZSx9nnmkMqOKaUARdWC2OTWs" & @CRLF & _
"" & @CRLF & _
"asdf=asdfasdf; osf=5633d9e768732dc8c7ca1f9a._7iTy0uvL_4eVBf_y_SzRVEeOII; csrftoken=ah8zV0tSZSx9nnmkMqOKaUARdWC2OTWs" & @CRLF & _
"" & @CRLF & _
"asfdasdf=asdfasdf; osf=5633d9e768732dc8c7ca1f9a._7iTy0uvL_4eVBf_y_SzRVEeOII" & @CRLF & _
"" & @CRLF & _
"osf=5633d9e768732dc8c7ca1f9a._7iTy0uvL_4eVBf_y_SzRVEeOII" & @CRLF & _
""
Local $sSubst = "\1"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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