in reply to A little regex help please!
Prints:#!/usr/bin/perl -w use strict; local $/; my $line = <DATA>; if($line=~m/(\d+):\s+From:\s+(.*?)(?=Length)/s){ print $1 . $2; } 1; __DATA__ There is a new voicemail in mailbox 11234567890: From: "Unknown" <Unknown> Length: 0:13 seconds Date: Thursday, January 19, 2006 at 11:35:01 AM
perl hate.pl 11234567890"Unknown" <Unknown>
Update:Okay, I have to ask it...how in the hell did you go 10 years coding in Perl without learning regexes?
Celebrate Intellectual Diversity
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A little regex help please!
by jdtoronto (Prior) on Feb 01, 2006 at 05:25 UTC | |
|
Re^2: A little regex help please!
by blazar (Canon) on Feb 01, 2006 at 11:18 UTC |