Solved

binkzz follow up question

Posted on 2000-03-21
2
172 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PERL get the value for query 4 155
add a syntax to a csv file 8 99
Matching a random pattern with one common character 2 75
Perl Versus AWK? 7 52
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…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…

830 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