Solved

binkzz follow up question

Posted on 2000-03-21
2
146 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now