For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2004 > Perl regular expression help









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Perl regular expression help
vasanthd

2004-07-23, 4:41 pm

Hello there,
I am a newbie towards perl I have one doubt in regular expressions. I am doing a search engine, and I need help on following criteria. I find a match, and I want to grab about 3 words before the match and about 3 words after the match, to include that in the description of the search results.
E.g. String = "The cat ran over the mouse to catch the ball and fell".
pattern = mouse

i need to grab - "ran over the mouse to catch the"

I tried the \b - word boundary, but i didnt know exactly how to fit that. Anyhelp is appreciated.

Thanks
Vas
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com