Link to home
Start Free TrialLog in
Avatar of boofulls
boofulls

asked on

binkzz follow up question

hi
u helped me with

https://www.experts-exchange.com/jsp/qShow.jsp?ta=perl&qid=10313986 

i asked for two versions where a word on either the
right or left was matched and shown

this time could u show 5 charcters to the left of the word
and 5 characters to the right of the word?

so if text is
"this is a test that i will test out now for a test run."
and wrd is "test"
i will get
is a test that
will test out
or a test run.

(note 5 characters are displayed on each side of the matched word

thanks
Avatar of binkzz
binkzz

#! /usr/bin/perl

$test = "this is a test that i will test out now for a test run.";
$word = "test";

my $templine = $test;


while ($templine =~ m/(.....)$word(.....)/is)
{
  $templine =~ s/(.....)$word(.....)//is;

  print "$1$word$2\n";
}
ASKER CERTIFIED SOLUTION
Avatar of binkzz
binkzz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial