develooper Front page | perl.beginners | Postings from January 2002

regexps with multiple matches and extended ASCII characters

Thread Next
From:
Birgit Kellner
Date:
January 4, 2002 07:21
Subject:
regexps with multiple matches and extended ASCII characters
Message ID:
3C35D4BD.25457.9041E27@localhost
use strict;
my $string = "!Rita 1983! and then some text and here is !Künne 1234!
and !Kußmaul 2001!";
while ($string =~ /!(\w+)\s(\d{4})!/gi) { print "$1 and $2\n";}
# prints "Rita and 1983"
while ($string =~ /!(\C+)\s(\d{4})!/gi) { print "$1 and $2\n";}
# prints "Rita 1983! and then some text and here is !Künne 1234! and
#!Kußmaul and 2001"

Why does this not print the following:

Rita and 1983
Künne and 1234
Kußmaul and 2001

And why is the regexp greedy with \C, but not with \w?

Birgit Kellner

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About