in reply to How to get the Pre-Match and Post-Match through Win32::OLE

gopalr u can try the following or u can use substr,

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->select; $a = $rng->text; $a='This is Sample Pre Match Text<web>www.hotmail.com</web>This is Sam +ple Post Match Text'; $a =~ m|<web>www\.hotmail\.com<\/web>|si; $pre= $`;$post= $'; ($pretext)= $pre =~ /(.{15})$/i; ($posttext)= $pre =~ /^(.{15})/i; print "pre:$pre\npost:$post\n"; print "\n\n"; print "pre:$pretext\npost:$posttext\n";

Prasad