in reply to Regex word options
Input:
Program:This line Transcribed, For David Jones # This line Arranged, For Mike Johnson (great) Terrible weather today
Output:#!/bin/perl my $file='regex.txt'; my $work = do { local $/; open my $fh, "<", $file or die "could not open $file: $!"; <$fh>; }; while ($work =~ /(Transcribed|Arranged),\s+For\s+([\w\s]+)/g) { print "Match: $1 Person: $2\n"; }
Comments:Match: Transcribed Person: David Jones Match: Arranged Person: Mike Johnson
The \b (word boundary) matches have been removed as they don't really do anything. Note that it looks for (Transcribed|Arranged) as suggested by other The code looks for normal alpha characters and spaces as a name, terminating on the first that doesn't match, but this can be easily changed
In Section
Seekers of Perl Wisdom