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 Textwww.hotmail.comThis is Sample Post Match Text';
$a =~ m|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";