bluethundr has asked for the wisdom of the Perl Monks concerning the following question:
-------------#!/usr/bin/perl -w use strict; while(<>) { chomp; if (/(\w+a\b)(\w{0,5})/) { print "Matched: |$`<'$1'>'$2'\n"; } else { print "No match: |$_|\n"; } }
Here is my sample text that I am working with: This is a line that has the name fred in it. This is a line that does not. This is a line that has the name barney in it. This is fred. This is notfred. Hello Fred Flintstone! Hello Fred! Allo allo, Alfred! Cheerio Mr. frederick! Hello Mr. Slate! Hello FRED! Hello Fred! Hello fred! This is some wilma text with some words in it this is fred. This is wilmafred. This is some more wilma text fred. Mrs. Wilma Flintstone wilma&fred wilma but not barney
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Contents of $2 empty
by ww (Archbishop) on Dec 22, 2008 at 14:51 UTC | |
|
Re: Contents of $2 empty
by ikegami (Patriarch) on Dec 22, 2008 at 14:06 UTC | |
|
Re: Contents of $2 empty
by jeanluca (Deacon) on Dec 22, 2008 at 14:19 UTC |