Mandar Rahurkar wrote:
Hi,
Hello,
I have a bunch of text (multiple paragraphs). I want to find a sentence like 'Susan * the water' (No its not a HW problem). Here's what I am doing:
#! /usr/bin/perl
use strict;
use warnings;
$file="temp.txt";
my $file = 'temp.txt';
open(fp,$file) or die "Cant open $file :$!\n";
open(FP,$file) or die "Can not open $file : $!\n";
local $/="";
why ??
while (<fp>) {
while(<FP>) {
while( /(susan)(\D+)[the|water]\b/xig ) { print "$1 $2\n" } }
this catches sentences like:
susan swam in the water for long time whereas i wud like susan swam in the water
What am i doing wrong ?
(\D+) matches more than you expect. What do you mean in "Susan * the water" with the *?
A word with no digits?
Try /(susan)\s+([a-zA-Z]+)\s+the water/
Mayeb if your a bit more descriptive of what you are trying to get
HTH :)
Lee.M - JupiterHost.Net
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>