Try searching the whole paragraph
poj#!perl use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; $Win32::OLE::Warn = 3; my $MSWord = Win32::OLE->new('Word.Application', 'Quit') or die Win32::OLE->LastError(); $MSWord->{Visible} = 0; my $doc = $MSWord->Documents->Open({FileName=>"c:/temp/2test.docx"}) or die Win32::OLE->LastError();; my $para = $doc->Paragraphs() ; my $enum = new Win32::OLE::Enum($para); my $sel = $MSWord->Selection; while ( defined (my $para = $enum->Next()) ) { my $txt = $para->Range->Text; while ( $txt =~ /([A-Z]{4}-[0-9])/g ){ $sel->Find->{Text} = $1; $sel->Find->Execute; my $page_num = $sel->Range->Information(wdActiveEndPageNumber); print "page $page_num .. ".$sel->Text."\n"; $sel->MoveRight({Count=>1,Unit=>wdWord}) } } $MSWord->ActiveDocument->Close ;
In reply to Re: Win32 Pattern issue
by poj
in thread Win32 Pattern issue
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |