in reply to Perl not printing any special characters in array
($domain) = $url =~ m|www.([A-Z a-z 0-9]+.{3}).|x;
Just a side note: The regex quoted above is unlikely to be doing what you expect.
c:\@Work\Perl\monks>perl -wMstrict -le "use YAPE::Regex::Explain; ;; my $rx = qr{www.([A-Z a-z 0-9]+.{3}).}x; ;; print YAPE::Regex::Explain->new($rx)->explain; " The regular expression: (?x-ims:www.([A-Z a-z 0-9]+.{3}).) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?x-ims: group, but do not capture (disregarding whitespace and comments) (case-sensitive) (with ^ and $ matching normally) (with . not matching \n): ---------------------------------------------------------------------- www 'www' ---------------------------------------------------------------------- . any character except \n ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- [A-Z a-z 0-9]+ any character of: 'A' to 'Z', ' ', 'a' to 'z', ' ', '0' to '9' (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- .{3} any character except \n (3 times) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- . any character except \n ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
Update: I'm not familiar with URL matching in general, but I cannot imagine this problem has not already been addressed in a Perl module — or modules! Maybe search CPAN or MetaCPAN with terms like URL regex
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl prints only last line of array
by myfrndjk (Sexton) on Jun 22, 2014 at 10:58 UTC | |
by AnomalousMonk (Archbishop) on Jun 22, 2014 at 17:12 UTC |