Pachan Posted August 12, 2010 Posted August 12, 2010 Hi Team, Please help me with this Pattern matching/stringRegExp problem. I am trying to extract the content between "Document Type" and next array entry. Please refer the "expected_output.txt" for more details. Note : Input file(print.doc) and expected_output.txt attached. My code: #include <Word.au3> #include <File.au3> #include <Excel.au3> local $arrayWrite[7] = ["MM_Procure to Pay","Business Processes","Purchase Requisition","Create Purchase Requisition","PR Report","Quotation","Request for Quotation"] $oWordApp = _WordCreate ("D:\TestLabs\PRINT.DOC") $sText = $oWordApp.Activedocument.Range.Text ;consoleWrite($sText) For $columnRead = 0 To 5 Step 1 ConsoleWrite(@CRLF & $arrayWrite[$columnRead] & @CRLF) ConsoleWrite(@CRLF & $arrayWrite[$columnRead+ 1] & @CRLF) $nOffset = 1 ;while 1 $stringbetweenRows = stringRegExp($sText,"(?i)(?s)" & $arrayWrite[$columnRead] & "(?i)(?s).+?Documentation Type: .+?Additional Documentation(.+?)" & $arrayWrite[$columnRead+1],1,$nOffset) if @error == 0 then ;ConsoleWrite(@crlf & $stringbetweenRows[0] & @crlf & "***************************************************" & @crlf) $nOffset = @extended Else ExitLoop endif for $i = 0 to UBound($stringbetweenRows) - 1 ConsoleWrite(@CRLF & $stringbetweenRows[$i] & @CRLF) Next ;WEnd next _WordQuit($oWordApp Thanks, ThomasPRINT.DOCExpected_output.txt
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now