[TriLUG] Regular Expression Help
Matthew Todd
matthew.todd at alumni.duke.edu
Wed Dec 24 11:45:47 EST 2003
On Wed, 2003-12-24 at 10:41, Tarus Balog wrote:
> I need a regular expression for the following:
>
> The characters "Re: " followed by 2 to 8 capital letters, followed by a
> comma and space ", " and then three random words, separated by spaces.
Hi, Tarus --
How about this: /^Re: [A-Z]{2,8}, \S+ \S+ \S+$/
Attached are a perl script and some test data. The script prints only
the lines from stdin that match the above re.
[mtodd at pippin mtodd]$ cat re-test-data | ./re.pl
Re: CEGRUJAV, finally the door
Re: WPXPM, them and came
Re: OIJ, what? what? what
HTH,
-- Matthew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: re.pl
Type: text/x-perl
Size: 60 bytes
Desc: not available
URL: <http://www.trilug.org/pipermail/trilug/attachments/20031224/07b00e20/attachment.pl>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: re-test-data
URL: <http://www.trilug.org/pipermail/trilug/attachments/20031224/07b00e20/attachment.ksh>
More information about the TriLUG
mailing list