Adriano Allora wrote:
hi to all,
I cannot use a negative match, and I cannot understand why: someone may
help me?
I've got this four rows (for instance):
araba ADJ arabo
arabo ADJ arabo
arabo NOM arabo
arano VER:pres arare
and, with this regular expression, I would extract only the fourth one:
my $form1 = qw(ara\w+);
my $pos1 = qw([A-Z]+);
my $lemma1 = qw(?!arabo);
my $pattern = "^(?:$form1)[^A-Z]*($pos1)[^A-Z]*($lemma1)\n";
but it doesn't work (the script extracts all the lines).
From `perldoc perlre`:
"(?!pattern)"
A zero-width negative look-ahead assertion.
This means $lemma1 will match a string of zero length, which is ALWAYS
before the newline.
Your problem is that you are trying to do too much with a single
pattern. You should avoid this because it makes understanding, and
therefore maintenance, difficult. Try:
if( /^ara/ && ! /arabo\n$/ && /([A-Z]+)/ ){
print "\$1 = $1\n";
print "yes: $_";
}else{
print "no : $_";
}
ANOTHER QUESTION: is there a module to merge different arrays and
extract equal values or I have to use a foreach statement?
No, Try:
my %hash = map { $_ => 1 } @array1;
for ( @array2 ){
push @both, $_ if $hash{$_};
}
--
Just my 0.00000002 million dollars worth,
--- Shawn
"Probability is now one. Any problems that are left are your own."
SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_
* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>