[Israel.pm] regular expressions problem

Srikanth Madani srikanth.madani at vodafone.com
Thu Feb 26 06:35:14 PST 2004


Here is my code which worked :

#!/usr/local/bin/perl -w
use strict;
use diagnostics;
my $str = "Title/Function: stam balalam
lhgfldddl lhflghdl lkdgldflgjd
bla bla bal

Status: write status here
write
status
here

Suggested Meetings:
jg jgkfj jglfdjlgjkdf
ljgldfjl fd
fg o;

Comments:  kjk k
kkk ll
gghghg

";
if (!($str =~ /^Title\/Function:([\d\D]*)Status:([\d\D]*)Suggested
Meetings:([\d\D]*)Comments:([\d\D]*)/)) {
        print "\nInput string does not conform to nomenclature rules.\n";
        exit 1;
}
print "\nTitle/Function is $1.\n";
print "\nStatus is $2.\n";
print "\nSuggested Meetings are $3.\n";
print "\nComments are $4.\n";


Cheers,
Srikanth Madani


-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il]On
Behalf Of Afgin Shlomit
Sent: Thursday, February 26, 2004 1:11 PM
To: perl at perl.org.il
Subject: [Israel.pm] regular expressions problem



I want to keep each title in different variable so I tried:
$str =~ /^(Title\/Function:\s+((.|\n)+))*(Status:\s+((.|\n)+))*(Suggested
Meetings:\s+((.|\n)+))*(Comments:\s+((.|\n)+))*$/;
print " $1\n $2\n $3\n $4\n $5\n $6";

I get in $1 all the $str. How I need to change my regular expresion so I
can get the words that apear after the titles
Thanks,
	Shlomit.




More information about the Perl mailing list