in reply to How to get the Pre-Match and Post-Match through Win32::OLE
Hi, gopal try this
use Win32::OLE; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Word'; $word=Win32::OLE->GetActiveObject('Word.Application'); $doc= $word->activedocument; $rng = $doc->{range}; $rng->find->clearformatting; $rng->find->replacement->clearformatting; $rng->select; $str = $rng->text; ($prematch,$postmatch)=$str =~ m#(.*?)<web>.*</web>(.*)#gsi; ($pre) = $prematch =~ m#(.{15})#gsi; ($post) = $postmatch =~ m#(.{15})#gsi; print "\n$pre"; print "\n$post"
|
|---|