#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(\S)[ \t]*(?:\r\n|\n)[ \t]*(\S)"
Local $sString = "Random Data, Company" & @CRLF & _
"2015" & @CRLF & _
"" & @CRLF & _
"This is a sentence that has line " & @CRLF & _
"break in the middle of it due to extracting from a PDF." & @CRLF & _
"" & @CRLF & _
"How do I support" & @CRLF & _
"3 line sentence " & @CRLF & _
"breaks please?" & @CRLF & _
"" & @CRLF & _
"HEADER HERE" & @CRLF & _
"" & @CRLF & _
"The first sentence will " & @CRLF & _
"match. However, this line will not match" & @CRLF & _
"for some reason " & @CRLF & _
"that I cannot figure out." & @CRLF & _
"" & @CRLF & _
"Portfolio: " & @CRLF & _
"http://DoNotMatchMeBecauseIHaveAPeriodInMe.com " & @CRLF & _
"" & @CRLF & _
"Full Name " & @CRLF & _
"San Francisco, CA " & @CRLF & _
"94000" & @CRLF & _
"" & @CRLF & _
"1500 testing a number as the first word in" & @CRLF & _
"a broken sentence." & @CRLF & _
"" & @CRLF & _
"Match sentences with capital letters on the next line like " & @CRLF & _
"Wi-Fi." & @CRLF & _
"" & @CRLF & _
"This line has " & @CRLF & _
"trailing spaces after exclamation mark! " & @CRLF & _
""
Local $sSubst = "\1 \2"
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