Solved

binkzz follow up question

Posted on 2000-03-21
2
167 Views
Last Modified: 2010-03-05
hi
u helped me with

http://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
0
Comment
Question by:boofulls
  • 2
2 Comments
 
LVL 4

Expert Comment

by:binkzz
ID: 2639771
#! /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";
}
0
 
LVL 4

Accepted Solution

by:
binkzz earned 100 total points
ID: 2639773
There ya go :)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question